Use new CPU-neutral program-memory API.
[bertos.git] / mware / sprintf_test.c
index b793f97b0138eb982b52972eae08c88f0b0bc052..5e68e79fff77ecfb92e5ead6e78e87bb2522dc41 100755 (executable)
@@ -17,9 +17,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 +26,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;
 }