summaryrefslogtreecommitdiff
path: root/src/user/app/tests/printf.c
diff options
context:
space:
mode:
authordzwdz2022-08-04 21:43:38 +0200
committerdzwdz2022-08-04 21:43:38 +0200
commit26dc784103914b9d6ba36e0a96fa4b3af977626f (patch)
treed1c9938bac9426d4f6709344315d845b45b20865 /src/user/app/tests/printf.c
parent81a58004d51547d074b4218f906b0b95f2b2c5dc (diff)
user/tests: split the tests by parts of codebase
Diffstat (limited to 'src/user/app/tests/printf.c')
-rw-r--r--src/user/app/tests/printf.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/user/app/tests/printf.c b/src/user/app/tests/printf.c
index 6c6c609..4dc45bb 100644
--- a/src/user/app/tests/printf.c
+++ b/src/user/app/tests/printf.c
@@ -1,32 +1,35 @@
-#define TEST_MACROS
#include "tests.h"
#include <stdio.h>
#include <string.h>
-void test_printf(void) {
+static void test_printf(void) {
char buf[64];
memset(buf, '?', 64);
/* test proper overflow handling in snprintf */
- assert(13 == snprintf(buf, 15, "That's 0x%x", 0x1337));
- assert(!memcmp(buf, "That's 0x1337\0??", 16));
- assert(17 == snprintf(buf, 15, "%05x %05x %05x", 0, 0, 0));
- assert(!memcmp(buf, "00000 00000 00\0?", 16));
+ test(13 == snprintf(buf, 15, "That's 0x%x", 0x1337));
+ test(!memcmp(buf, "That's 0x1337\0??", 16));
+ test(17 == snprintf(buf, 15, "%05x %05x %05x", 0, 0, 0));
+ test(!memcmp(buf, "00000 00000 00\0?", 16));
/* all the other stuff */
snprintf(buf, sizeof buf, "%010x", 0x1BABE);
- assert(!strcmp(buf, "000001babe"));
+ test(!strcmp(buf, "000001babe"));
snprintf(buf, sizeof buf, "%10x", 0x1BABE);
- assert(!strcmp(buf, " 1babe"));
+ test(!strcmp(buf, " 1babe"));
snprintf(buf, sizeof buf, "%10s", "hello");
- assert(!strcmp(buf, " hello"));
+ test(!strcmp(buf, " hello"));
snprintf(buf, sizeof buf, "%s%%%s", "ab", "cd");
- assert(!strcmp(buf, "ab%cd"));
+ test(!strcmp(buf, "ab%cd"));
snprintf(buf, sizeof buf, "%05u %05u", 1234, 56789);
- assert(!strcmp(buf, "01234 56789"));
+ test(!strcmp(buf, "01234 56789"));
snprintf(buf, sizeof buf, "%u %x", 0, 0);
- assert(!strcmp(buf, "0 0"));
+ test(!strcmp(buf, "0 0"));
+}
+
+void r_printf(void) {
+ run_test(test_printf);
}