summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/_itow/test1
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/_itow/test1')
-rw-r--r--src/pal/tests/palsuite/c_runtime/_itow/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/_itow/test1/test1.c102
-rw-r--r--src/pal/tests/palsuite/c_runtime/_itow/test1/testinfo.dat18
3 files changed, 139 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/_itow/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_itow/test1/CMakeLists.txt
new file mode 100644
index 0000000000..bd37f31216
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_itow/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_itow_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_itow_test1 coreclrpal)
+
+target_link_libraries(paltest_itow_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/_itow/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_itow/test1/test1.c
new file mode 100644
index 0000000000..745ce4acaa
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_itow/test1/test1.c
@@ -0,0 +1,102 @@
+// 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: Tests the PAL implementation of the _itow function.
+** Test a number of ints with different radix on each,
+** to ensure that the string returned is correct.
+**
+**
+**===================================================================*/
+
+#define UNICODE
+
+#include <palsuite.h>
+
+struct testCase
+{
+ wchar_t *CorrectResult;
+ int value;
+ int radix;
+};
+
+int __cdecl main(int argc, char **argv)
+{
+
+ wchar_t result[20];
+ wchar_t *pResult = NULL;
+ char *PrintResult = NULL; /* Use with convertC so we can */
+ char *PrintCorrectResult = NULL; /* print out the results */
+ int i = 0;
+
+ WCHAR case1[] = {'5','0','\0'};
+ WCHAR case2[] = {'5','5','5','\0'};
+ WCHAR case3[] = {'1','0','1','0','\0'};
+ WCHAR case4[] = {'2','2','\0'};
+ WCHAR case5[] = {'a','\0'};
+ WCHAR case6[] = {'c','g','\0'};
+
+ /* Correct Result, Value to Convert, Radix to use */
+ struct testCase testCases[] =
+ {
+ {case1, 50, 10},
+ {case2,555,10},
+ {case3,10,2},
+ {case4,10,4},
+ {case5,10,16},
+ {case6,400,32}
+ };
+
+ /*
+ * Initialize the PAL and return FAIL if this fails
+ */
+ if (0 != (PAL_Initialize(argc, argv)))
+ {
+ return FAIL;
+ }
+
+ /* Loop through each case. Convert the ints to strings. Check
+ to ensure they were converted properly.
+ */
+
+ for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++)
+ {
+ pResult = _itow(testCases[i].value,result,testCases[i].radix);
+
+ if(pResult != &result[0])
+ {
+ Fail("ERROR: _itow didn't return a correct pointer to the "
+ "newly formed string.\n");
+ }
+
+ if (0 != wcscmp(testCases[i].CorrectResult,pResult))
+ {
+ PrintResult = convertC(pResult);
+ PrintCorrectResult = convertC(testCases[i].CorrectResult);
+ Fail("ERROR: _itow was called on %i, returning the string %s "
+ "when it should have returned the string %s.\n"
+ , testCases[i].value, PrintResult, PrintCorrectResult);
+ }
+
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pal/tests/palsuite/c_runtime/_itow/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_itow/test1/testinfo.dat
new file mode 100644
index 0000000000..394c34dff3
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/_itow/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 = _itow
+Name = Positive Test for _itow
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Tests the PAL implementation of the _itow function.
+= Test a number of ints with different radix on each, to ensure that the
+= string returned is correct.
+
+
+
+