summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/_strnicmp/test1
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/_strnicmp/test1')
-rw-r--r--src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.c85
-rw-r--r--src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat18
3 files changed, 122 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt
new file mode 100644
index 0000000..6a38747
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_strnicmp_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_strnicmp_test1 coreclrpal)
+
+target_link_libraries(paltest_strnicmp_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.c
new file mode 100644
index 0000000..3c915dc
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.c
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*============================================================================
+**
+** Source: test1.c
+**
+** Purpose: Test #1 for the _strnicmp function
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ char str1[] = "foo";
+ char str2[] = "foox";
+ char str3[] = "fOo";
+ char str4[] = "ABCDE";
+ char str5[] = "ABCD[";
+ char str6[] = "abcde";
+ char str7[] = "abcd^";
+
+ /*
+ * Initialize the PAL and return FAIL if this fails
+ */
+ if (0 != (PAL_Initialize(argc, argv)))
+ {
+ return FAIL;
+ }
+
+ if (_strnicmp(str1, str2, strlen(str2)) >= 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned >= 0\n",
+ str1, str2, strlen(str2));
+ }
+
+ if (_strnicmp(str2, str1, strlen(str2)) <= 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned <= 0\n",
+ str2, str1, strlen(str2));
+ }
+
+ if (_strnicmp(str1, str2, strlen(str1)) != 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned != 0\n",
+ str1, str2, strlen(str1));
+ }
+
+ if (_strnicmp(str1, str3, strlen(str1)) != 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned != 0\n",
+ str1, str3, strlen(str3));
+ }
+
+ if (_strnicmp(str3, str1, strlen(str1)) != 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned != 0\n",
+ str3, str1, strlen(str1));
+ }
+
+ /* new testing */
+
+ /* str4 should be greater than str5 */
+ if (_strnicmp(str4, str5, strlen(str4)) <= 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned >= 0\n",
+ str4, str5, strlen(str4));
+ }
+
+ /* str6 should be greater than str7 */
+ if (_strnicmp(str6, str7, strlen(str6)) <= 0)
+ {
+ Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned <= 0\n",
+ str6, str7, strlen(str6));
+ }
+
+
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat
new file mode 100644
index 0000000..86744c0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat
@@ -0,0 +1,18 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+
+Version = 1.0
+Section = C Runtime
+Function = _strnicmp
+Name = Test #1 for _strnicmp
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Take two strings and compare them, giving different lengths.
+= Comparing str1 and str2 with str2 length, should return <0
+= Comparing str2 and str1 with str2 length, should return >0
+= Comparing str1 and str2 with str1 lenght, should return 0
+= Bring in str3, which has a capital, but this function is doing a lower
+= case compare. Just ensure that two strings which differ only by capitals
+= return 0.