aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/tests/test_printf.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-09-27 18:16:46 +0200
committerMartin Willi <martin@revosec.ch>2013-10-11 11:06:09 +0200
commit795cbb98c6950d732f112063bd16de02ec54db67 (patch)
tree05fd3b8922ef17eadc2e16ca3f6f44f02d10fe87 /src/libstrongswan/tests/test_printf.c
parent8af9bf70f5d41b10d635974d5723d104f50f3274 (diff)
downloadstrongswan-795cbb98c6950d732f112063bd16de02ec54db67.tar.bz2
strongswan-795cbb98c6950d732f112063bd16de02ec54db67.tar.xz
printf-hook-builtin: Print NaN/Infinity floating point values as such
Diffstat (limited to 'src/libstrongswan/tests/test_printf.c')
-rw-r--r--src/libstrongswan/tests/test_printf.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstrongswan/tests/test_printf.c b/src/libstrongswan/tests/test_printf.c
index a7b19d96e..6c15fbea1 100644
--- a/src/libstrongswan/tests/test_printf.c
+++ b/src/libstrongswan/tests/test_printf.c
@@ -16,6 +16,7 @@
#include "test_suite.h"
#include <errno.h>
+#include <math.h>
static void verify(char *expected, char *format, ...)
{
@@ -133,6 +134,19 @@ START_TEST(test_printf_float)
verify("-1.12", "%.2f", -1.1249);
verify("-1.124", "%.3f", -1.12351);
verify("-1.123", "%.3f", -1.12349);
+
+#ifdef NAN
+ verify("nan", "%.3f", NAN);
+ verify(" nan", "%5.3f", NAN);
+ verify("NAN", "%.3F", NAN);
+ verify("NAN ", "%-5.3F", NAN);
+#endif
+#ifdef INFINITY
+ verify("inf", "%.3f", INFINITY);
+ verify("-inf", "%.4f", -INFINITY);
+ verify("INF", "%.3F", INFINITY);
+ verify("-INF", "%.4F", -INFINITY);
+#endif
}
END_TEST