summaryrefslogtreecommitdiff
path: root/tests/port
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-03-24 13:30:02 +0100
committerAndreas Baumann <abaumann@yahoo.com>2009-03-24 13:30:02 +0100
commitbc7a5d8980f1d0a507f5593347ee425d864de79c (patch)
tree766baa18eff49167a606543b4555e15d375b362b /tests/port
parentb305975aaf8052277406ad11291bec3cdce93dff (diff)
downloadwolfbones-bc7a5d8980f1d0a507f5593347ee425d864de79c.tar.gz
wolfbones-bc7a5d8980f1d0a507f5593347ee425d864de79c.tar.bz2
added a simple itoa
Diffstat (limited to 'tests/port')
-rw-r--r--tests/port/GNUmakefile5
-rw-r--r--tests/port/Makefile.W325
-rw-r--r--tests/port/test_itoa.c21
3 files changed, 29 insertions, 2 deletions
diff --git a/tests/port/GNUmakefile b/tests/port/GNUmakefile
index 0b0f30c..47f0a61 100644
--- a/tests/port/GNUmakefile
+++ b/tests/port/GNUmakefile
@@ -14,7 +14,8 @@ TEST_BINS = \
test_localtime_r$(EXE) \
test_snprintf$(EXE) \
test_strlcpy$(EXE) \
- test_strlcat$(EXE)
+ test_strlcat$(EXE) \
+ test_itoa$(EXE)
-include $(TOPDIR)/makefiles/gmake/sub.mk
@@ -48,3 +49,5 @@ local_test:
@./test_strlcpy > /dev/null
@echo "Testing strlcat.."
@./test_strlcat > /dev/null
+ @echo "Testing itoa.."
+ @./test_itoa > /dev/null
diff --git a/tests/port/Makefile.W32 b/tests/port/Makefile.W32
index 958cbff..58da09b 100644
--- a/tests/port/Makefile.W32
+++ b/tests/port/Makefile.W32
@@ -14,7 +14,8 @@ TEST_BINS = \
test_localtime_r.exe \
test_snprintf.exe \
test_strlcpy.exe \
- test_strlcat.exe
+ test_strlcat.exe \
+ test_itoa.exe
!INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk
@@ -49,3 +50,5 @@ local_test:
@test_strlcpy >NUL 2>NUL
@echo Testing strlcat..
@test_strlcat >NUL 2>NUL
+ @echo Testing itoa..
+ @test_itoa >NUL 2>NUL
diff --git a/tests/port/test_itoa.c b/tests/port/test_itoa.c
new file mode 100644
index 0000000..84c72f2
--- /dev/null
+++ b/tests/port/test_itoa.c
@@ -0,0 +1,21 @@
+#include "port/sys.h"
+
+#define TEST_ITOA
+#include "port/stdlib.c" /* for itoa, exit, EXIT_SUCCESS */
+
+int main( void ) {
+ char s1[20];
+ char s2[20];
+
+ wolf_port_itoa( 4711, s1, 10 );
+ itoa( 4711, s2, 10 );
+ if( strcmp( s1, "4711" ) != 0 ) return EXIT_FAILURE;
+ if( strcmp( s1, s2 ) != 0 ) return EXIT_FAILURE;
+
+ wolf_port_itoa( 4711, s1, 16 );
+ itoa( 4711, s2, 16 );
+ if( strcmp( s1, "1267" ) != 0 ) return EXIT_FAILURE;
+ if( strcmp( s1, s2 ) != 0 ) return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
+}