diff options
Diffstat (limited to 'firmware/test/snprintf')
| -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 0000000..39f128e --- /dev/null +++ b/firmware/test/snprintf/Makefile @@ -0,0 +1,16 @@ + +TARGET = snprintf + +OBJS = snprintf.o test.o + +CFLAGS = -I../../include + +$(TARGET): $(OBJS) + +snprintf.o: ../../common/sprintf.c + $(CC) -c $< -o $@ + +test.o: test.c + +clean: + 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 0000000..8923c9c --- /dev/null +++ b/firmware/test/snprintf/test.c @@ -0,0 +1,17 @@ + +#include <stdio.h> + +#include "sprintf.h" + +int main(int argc, char **argv) +{ + char buffer[256]; + snprintf(buffer, 5, "123456789"); + printf("%s\n", buffer); + snprintf(buffer, 6, "123456789"); + printf("%s\n", buffer); + snprintf(buffer, 7, "123456789"); + printf("%s\n", buffer); + snprintf(buffer, 7, "123%s", "mooooooooooo"); + printf("%s\n", buffer); +} |