diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/c_runtime/wcstoul | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2 coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/wcstoul')
19 files changed, 547 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/CMakeLists.txt new file mode 100644 index 0000000000..7c20179353 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test2) +add_subdirectory(test3) +add_subdirectory(test4) +add_subdirectory(test5) +add_subdirectory(test6) + diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/CMakeLists.txt new file mode 100644 index 0000000000..b24523e93b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/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_wcstoul_test1 + ${SOURCES} +) + +add_dependencies(paltest_wcstoul_test1 coreclrpal) + +target_link_libraries(paltest_wcstoul_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/test1.c b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/test1.c new file mode 100644 index 0000000000..5274905e30 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/test1.c @@ -0,0 +1,49 @@ +// 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 wcstoul function +** +** +**==========================================================================*/ +#include <palsuite.h> + +/* + * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR teststr[] = {'1','2','3','4','5',0}; + WCHAR *end; + ULONG result = 27; + ULONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstoul(teststr, &end, 4); + + if (l != result) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", result, l); + } + + if (end != teststr + 3) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + teststr + 3, end); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/testinfo.dat new file mode 100644 index 0000000000..af4fb7e55d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/testinfo.dat @@ -0,0 +1,12 @@ +# 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 = wcstoul +Name = Positive Test for wcstoul +TYPE = DEFAULT +EXE1 = test1 +Description += Tests wcstoul with base 4 and a string that includes some invalid characters. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/CMakeLists.txt new file mode 100644 index 0000000000..e262078e34 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test2.c +) + +add_executable(paltest_wcstoul_test2 + ${SOURCES} +) + +add_dependencies(paltest_wcstoul_test2 coreclrpal) + +target_link_libraries(paltest_wcstoul_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/test2.c b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/test2.c new file mode 100644 index 0000000000..2ab2dbf5d1 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/test2.c @@ -0,0 +1,49 @@ +// 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: test2.c +** +** Purpose: Test #2 for the wcstoul function +** +** +**==========================================================================*/ +#include <palsuite.h> + +/* + * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR teststr[] = {'1','2','3','4','5',0}; + WCHAR *end; + ULONG result = 12345; + ULONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstoul((wchar_t*)teststr, &end, 10); + + if (l != result) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", result, l); + } + + if (end != teststr + 5) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + teststr + 5, end); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/testinfo.dat new file mode 100644 index 0000000000..b7e301f423 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/testinfo.dat @@ -0,0 +1,12 @@ +# 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 = wcstoul +Name = Positive Test for wcstoul +TYPE = DEFAULT +EXE1 = test2 +Description += Tests wcstoul with base 10 and a completely valid string. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/CMakeLists.txt new file mode 100644 index 0000000000..aae268ac59 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test3.c +) + +add_executable(paltest_wcstoul_test3 + ${SOURCES} +) + +add_dependencies(paltest_wcstoul_test3 coreclrpal) + +target_link_libraries(paltest_wcstoul_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/test3.c b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/test3.c new file mode 100644 index 0000000000..eac46615e2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/test3.c @@ -0,0 +1,49 @@ +// 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: test3.c +** +** Purpose: Test #3 for the wcstoul function +** +** +**==========================================================================*/ +#include <palsuite.h> + +/* + * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR str[] = {'Z',0}; + WCHAR *end; + ULONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstoul(str, &end, 10); + + if (l != 0) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", 0, l); + } + + if (end != str) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + str, end); + } + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/testinfo.dat new file mode 100644 index 0000000000..f7f6302d79 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/testinfo.dat @@ -0,0 +1,12 @@ +# 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 = wcstoul +Name = Positive Test for wcstoul +TYPE = DEFAULT +EXE1 = test3 +Description += Tests wcstoul with a completely invalid string (base 10). diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/CMakeLists.txt new file mode 100644 index 0000000000..bd8073023f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test4.c +) + +add_executable(paltest_wcstoul_test4 + ${SOURCES} +) + +add_dependencies(paltest_wcstoul_test4 coreclrpal) + +target_link_libraries(paltest_wcstoul_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/test4.c b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/test4.c new file mode 100644 index 0000000000..0261da4275 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/test4.c @@ -0,0 +1,52 @@ +// 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: test4.c +** +** Purpose: Test #4 for the wcstoul function +** +** +**==========================================================================*/ +#include <palsuite.h> + +/* + * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR maxstr[] = {'4','2','9','4','9','6','7','2','9','5',0}; + ULONG max = 4294967295ul; + WCHAR *end; + ULONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + errno = 0; + + l = wcstoul(maxstr, &end, 10); + if (l != max) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", max, l); + } + if (end != maxstr + 10) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + maxstr + 10, end); + } + if (errno != 0) + { + Fail("ERROR: wcstoul set errno to non-zero (%d)\n", errno); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/testinfo.dat new file mode 100644 index 0000000000..301178be3a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/testinfo.dat @@ -0,0 +1,12 @@ +# 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 = wcstoul +Name = Positive Test for wcstoul +TYPE = DEFAULT +EXE1 = test4 +Description += Tests wcstoul with base 10 and the highest possible value. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/CMakeLists.txt new file mode 100644 index 0000000000..1451e6ad57 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test5.c +) + +add_executable(paltest_wcstoul_test5 + ${SOURCES} +) + +add_dependencies(paltest_wcstoul_test5 coreclrpal) + +target_link_libraries(paltest_wcstoul_test5 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.c b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.c new file mode 100644 index 0000000000..00287cf7f4 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.c @@ -0,0 +1,69 @@ +// 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: test5.c +** +** Purpose: Test #5 for the wcstoul function +** +** +**==========================================================================*/ +#include <palsuite.h> + +/* + * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR overstr[] = {'4','2','9','4','9','6','7','2','9','6',0}; + WCHAR understr[] = {'-','1',0}; + WCHAR *end; + ULONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + errno = 0; + l = wcstoul(overstr, &end, 10); + + if (l != ULONG_MAX) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", ULONG_MAX, l); + } + if (end != overstr + 10) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + overstr + 10, end); + } + if (errno != ERANGE) + { + Fail("ERROR: wcstoul did not set errno to ERANGE (%d)\n", errno); + } + + errno = 0; + l = wcstoul(understr, &end, 10); + + if (l != ULONG_MAX) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", ULONG_MAX, l); + } + if (end != understr + 2) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + understr + 2, end); + } + if (errno != 0) + { + Fail("ERROR: wcstoul set errno to non-zero (%d)\n", errno); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/testinfo.dat new file mode 100644 index 0000000000..bf7b2b6fe0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/testinfo.dat @@ -0,0 +1,13 @@ +# 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 = wcstoul +Name = Positive Test for wcstoul +TYPE = DEFAULT +EXE1 = test5 +Description += Tests wcstoul (base 10) with underflowing and overflowing. += Chesks that errno gets set to ERANGE. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/CMakeLists.txt new file mode 100644 index 0000000000..15518bdcf8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test6.c +) + +add_executable(paltest_wcstoul_test6 + ${SOURCES} +) + +add_dependencies(paltest_wcstoul_test6 coreclrpal) + +target_link_libraries(paltest_wcstoul_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/test6.c b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/test6.c new file mode 100644 index 0000000000..28397ec73f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/test6.c @@ -0,0 +1,83 @@ +// 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: test6.c +** +** Purpose: Test #6 for the wcstoul function. Tests strings with octal/hex +** number specifers +** +** +**==========================================================================*/ +#include <palsuite.h> + + +/* + * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR test1[] = {'0','x','1','2', 0}; + WCHAR test2[] = {'0','1','2',0}; + WCHAR *end; + ULONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstoul(test1, &end, 16); + if (l != 0x12) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", 0x12, l); + } + if (end != test1 + 4) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + test1 + 4, end); + } + + l = wcstoul(test1, &end, 10); + if (l != 0) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", 0, l); + } + if (end != test1+1) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + test1+1, end); + } + + l = wcstoul(test2, &end, 8); + if (l != 10) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", 10, l); + } + if (end != test2 + 3) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + test2 + 3, end); + } + + l = wcstoul(test2, &end, 10); + if (l != 12) + { + Fail("ERROR: Expected wcstoul to return %u, got %u\n", 12, l); + } + + if (end != test2 + 3) + { + Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", + test2 + 3, end); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/testinfo.dat new file mode 100644 index 0000000000..40e18d540d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/testinfo.dat @@ -0,0 +1,12 @@ +# 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 = wcstoul +Name = Positive Test for wcstoul +TYPE = DEFAULT +EXE1 = test6 +Description += Tests wcstoul with hex and octal strings, with different bases. |