Merge "Extra tests for printf of NaN and Inf."

This commit is contained in:
Elliott Hughes 2014-04-14 21:07:24 +00:00 committed by Gerrit Code Review
commit 0558906866

View File

@ -18,6 +18,7 @@
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -302,6 +303,24 @@ TEST(stdio, snprintf_smoke) {
EXPECT_STREQ("print_me_twice print_me_twice", buf);
}
TEST(stdio, snprintf_f_special) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%f", nanf(""));
EXPECT_STREQ("NaN", buf);
snprintf(buf, sizeof(buf), "%f", HUGE_VALF);
EXPECT_STREQ("Inf", buf);
}
TEST(stdio, snprintf_g_special) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%g", nan(""));
EXPECT_STREQ("NaN", buf);
snprintf(buf, sizeof(buf), "%g", HUGE_VAL);
EXPECT_STREQ("Inf", buf);
}
TEST(stdio, snprintf_d_INT_MAX) {
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "%d", INT_MAX);