From 2955a2ead367c14169a74cfc2557d0ceb2bd334f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 16 Mar 2003 19:12:48 +0000 Subject: initial test code for the snprintf() (and family) function git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3449 a1c6a512-1295-4272-9138-f99709370657 --- firmware/test/snprintf/Makefile | 16 ++++++++++++++++ firmware/test/snprintf/test.c | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 firmware/test/snprintf/Makefile create mode 100644 firmware/test/snprintf/test.c 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 @@ + +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 0000000000..8923c9c9f5 --- /dev/null +++ b/firmware/test/snprintf/test.c @@ -0,0 +1,17 @@ + +#include + +#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); +} -- cgit v1.2.3