forked from len0rd/rockbox
initial test code for the snprintf() (and family) function
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3449 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e5e9bc3e65
commit
2955a2ead3
2 changed files with 33 additions and 0 deletions
16
firmware/test/snprintf/Makefile
Normal file
16
firmware/test/snprintf/Makefile
Normal file
|
@ -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)
|
17
firmware/test/snprintf/test.c
Normal file
17
firmware/test/snprintf/test.c
Normal file
|
@ -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);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue