diff options
-rw-r--r-- | firmware/test/snprintf/Makefile | 16 | ||||
-rw-r--r-- | firmware/test/snprintf/test.c | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/firmware/test/snprintf/Makefile b/firmware/test/snprintf/Makefile new file mode 100644 index 0000000000..39f128ed8a --- /dev/null +++ b/firmware/test/snprintf/Makefile | |||
@@ -0,0 +1,16 @@ | |||
1 | |||
2 | TARGET = snprintf | ||
3 | |||
4 | OBJS = snprintf.o test.o | ||
5 | |||
6 | CFLAGS = -I../../include | ||
7 | |||
8 | $(TARGET): $(OBJS) | ||
9 | |||
10 | snprintf.o: ../../common/sprintf.c | ||
11 | $(CC) -c $< -o $@ | ||
12 | |||
13 | test.o: test.c | ||
14 | |||
15 | clean: | ||
16 | rm -f $(OBJS) \ No newline at end of file | ||
diff --git a/firmware/test/snprintf/test.c b/firmware/test/snprintf/test.c new file mode 100644 index 0000000000..8923c9c9f5 --- /dev/null +++ b/firmware/test/snprintf/test.c | |||
@@ -0,0 +1,17 @@ | |||
1 | |||
2 | #include <stdio.h> | ||
3 | |||
4 | #include "sprintf.h" | ||
5 | |||
6 | int main(int argc, char **argv) | ||
7 | { | ||
8 | char buffer[256]; | ||
9 | snprintf(buffer, 5, "123456789"); | ||
10 | printf("%s\n", buffer); | ||
11 | snprintf(buffer, 6, "123456789"); | ||
12 | printf("%s\n", buffer); | ||
13 | snprintf(buffer, 7, "123456789"); | ||
14 | printf("%s\n", buffer); | ||
15 | snprintf(buffer, 7, "123%s", "mooooooooooo"); | ||
16 | printf("%s\n", buffer); | ||
17 | } | ||