CPU_CSOURCE(): New macro.
[bertos.git] / mware / sprintf_test.c
index b793f97b0138eb982b52972eae08c88f0b0bc052..0f4758f9bf593e844eb6dd0ccf9879da3cf90256 100755 (executable)
@@ -1,5 +1,6 @@
 #include "sprintf.c"
 #include "formatwr.c"
+#include "hex.c"
 
 #include <assert.h> /* assert() */
 #include <string.h> /* strcmp() */
@@ -17,9 +18,6 @@ int main(UNUSED_ARG(int, argc), UNUSED_ARG(char **,argv))
        snprintf(buf, sizeof buf, "%S", test_string_pgm);
        assert(strcmp(buf, test_string_pgm) == 0);
 
-       snprintf(buf, sizeof buf, "%s", NULL);
-       assert(strcmp(buf, "<NULL>") == 0);
-
        snprintf(buf, sizeof buf, "%d", 12345);
        assert(strcmp(buf, "12345") == 0);
 
@@ -29,5 +27,14 @@ int main(UNUSED_ARG(int, argc), UNUSED_ARG(char **,argv))
        snprintf(buf, sizeof buf, "%lu", 4294967295UL);
        assert(strcmp(buf, "4294967295") == 0);
 
+       /*
+        * Stress tests.
+        */
+       snprintf(buf, sizeof buf, "%s", NULL);
+       assert(strcmp(buf, "<NULL>") == 0);
+       snprintf(buf, sizeof buf, "%k");
+       assert(strcmp(buf, "???") == 0);
+       sprintf(NULL, test_string); /* must not crash */
+
        return 0;
 }