Added some regression tests from patch #2321830
[fw/sdcc] / support / regression / tests / strncmp.c
diff --git a/support/regression/tests/strncmp.c b/support/regression/tests/strncmp.c
new file mode 100644 (file)
index 0000000..79d53bd
--- /dev/null
@@ -0,0 +1,16 @@
+/** tests for strncmp
+*/
+#include <testfwk.h>
+#include <string.h>
+
+static void 
+teststrncmp(void)
+{
+  ASSERT( strncmp("", "", 0) == 0);
+  ASSERT( strncmp("ab", "ab", 0) == 0);
+  ASSERT( strncmp("a", "a", 2) == 0);
+  ASSERT( strncmp("aa", "ab", 1) == 0);
+  ASSERT( strncmp("aa", "ab", 2) < 0);
+  ASSERT( strncmp("abc", "abd", 2) == 0);
+  ASSERT( strncmp("abc", "abc", 3) == 0);
+}