diff options
author | Elliott Hughes <enh@google.com> | 2014-04-14 12:11:28 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-04-14 12:11:28 -0700 |
commit | 7823f320b144bc95a34389e7ab709c9e4d3073e1 (patch) | |
tree | 1eb9aca80fec80533bc236efed3a711a4ae75cd1 /tests/stdio_test.cpp | |
parent | 28417eb9b58ca666355f93e82dcad0df0d3466ce (diff) |
Extra tests for printf of NaN and Inf.
Change-Id: I61fc655d9777a03aabf38f6ebd047fe275386f05
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r-- | tests/stdio_test.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index cc1fd85c1..0aa1d15b2 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -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); |