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/wcstol | |
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/wcstol')
19 files changed, 593 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/CMakeLists.txt new file mode 100644 index 0000000000..7c20179353 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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/wcstol/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test1/CMakeLists.txt new file mode 100644 index 0000000000..25e96e7de0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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_wcstol_test1 + ${SOURCES} +) + +add_dependencies(paltest_wcstol_test1 coreclrpal) + +target_link_libraries(paltest_wcstol_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test1/test1.c b/src/pal/tests/palsuite/c_runtime/wcstol/test1/test1.c new file mode 100644 index 0000000000..d84ba66adc --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/test1/test1.c @@ -0,0 +1,53 @@ +// 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 wcstol function. Does a simple test with radix 4. +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + + +/* + * Notes: wcstol should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR *end; + WCHAR teststr[] = {'1','2','3','4','5',0}; + LONG result = 27; + LONG l; + + if ( 0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstol(teststr, &end, 4); + + if (l != result) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", result, l); + } + + if (end != teststr + 3) + { + Fail("ERROR: Expected wcstol 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/wcstol/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test1/testinfo.dat new file mode 100644 index 0000000000..48108f22bf --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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 = wcstol +Name = Positive Test for wcstol +TYPE = DEFAULT +EXE1 = test1 +Description += Tests wcstol with base 4 and a string that includes some invalid characters. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test2/CMakeLists.txt new file mode 100644 index 0000000000..ea33ec8c7e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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_wcstol_test2 + ${SOURCES} +) + +add_dependencies(paltest_wcstol_test2 coreclrpal) + +target_link_libraries(paltest_wcstol_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test2/test2.c b/src/pal/tests/palsuite/c_runtime/wcstol/test2/test2.c new file mode 100644 index 0000000000..58309be6b4 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/test2/test2.c @@ -0,0 +1,53 @@ +// 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 wcstol function. Does a simple test with radix +** 10. +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + + +/* + * Notes: wcstol should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR *end; + WCHAR teststr[] = {'1','2','3','4','5',0}; + LONG result = 12345; + LONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstol(teststr, &end, 10); + + if (l != result) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", result, l); + } + + if (end != teststr + 5) + { + Fail("ERROR: Expected wcstol 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/wcstol/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test2/testinfo.dat new file mode 100644 index 0000000000..8dd1460010 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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 = wcstol +Name = Positive Test for wcstol +TYPE = DEFAULT +EXE1 = test2 +Description += Tests wcstol with base 10 and a completely valid string. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test3/CMakeLists.txt new file mode 100644 index 0000000000..509feca08c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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_wcstol_test3 + ${SOURCES} +) + +add_dependencies(paltest_wcstol_test3 coreclrpal) + +target_link_libraries(paltest_wcstol_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test3/test3.c b/src/pal/tests/palsuite/c_runtime/wcstol/test3/test3.c new file mode 100644 index 0000000000..8b5ce6943d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/test3/test3.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: test3.c +** +** Purpose: Test #3 for the wcstol function. Tests an invalid string +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + + +/* + * Notes: wcstol 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; + LONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstol(str, &end, 10); + + if (l != 0) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", 0, l); + } + + if (end != str) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + str + 3, end); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test3/testinfo.dat new file mode 100644 index 0000000000..0e851d8657 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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 = wcstol +Name = Positive Test for wcstol +TYPE = DEFAULT +EXE1 = test3 +Description += Tests wcstol with a completely invalid string (base 10). diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test4/CMakeLists.txt new file mode 100644 index 0000000000..043c562102 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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_wcstol_test4 + ${SOURCES} +) + +add_dependencies(paltest_wcstol_test4 coreclrpal) + +target_link_libraries(paltest_wcstol_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test4/test4.c b/src/pal/tests/palsuite/c_runtime/wcstol/test4/test4.c new file mode 100644 index 0000000000..a5e65946e9 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/test4/test4.c @@ -0,0 +1,77 @@ +// 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 wcstol function. Tests the limits of the +** conversions. +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + + +/* + * Notes: wcstol should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR maxstr[] = {'2','1','4','7','4','8','3','6','4','7',0}; + LONG max = 2147483647; + WCHAR minstr[] = {'-','2','1','4','7','4','8','3','6','4','8',0}; + LONG min = 0x80000000; /* putting -2147483648 gives a warning */ + WCHAR *end; + LONG l; + + if ( 0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + errno = 0; + + l = wcstol(maxstr, &end, 10); + + if (l != max) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", max, l); + } + if (end != maxstr + 10) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + maxstr + 10, end); + } + if (errno != 0) + { + Fail("ERROR: wcstol set errno to non-zero (%d)\n", errno); + } + + + l = wcstol(minstr, &end, 10); + + if (l != min) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", min, l); + } + if (end != minstr + 11) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + minstr + 11, end); + } + if (errno != 0) + { + Fail("ERROR: wcstol set errno to non-zero (%d)\n", errno); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test4/testinfo.dat new file mode 100644 index 0000000000..d2c5652e6e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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 = wcstol +Name = Positive Test for wcstol +TYPE = DEFAULT +EXE1 = test4 +Description += Tests wcstol with base 10 and the highest and lowest possible values. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test5/CMakeLists.txt new file mode 100644 index 0000000000..c887369880 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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_wcstol_test5 + ${SOURCES} +) + +add_dependencies(paltest_wcstol_test5 coreclrpal) + +target_link_libraries(paltest_wcstol_test5 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test5/test5.c b/src/pal/tests/palsuite/c_runtime/wcstol/test5/test5.c new file mode 100644 index 0000000000..62f0a895a6 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/test5/test5.c @@ -0,0 +1,76 @@ +// 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 wcstol function. Tests over and under flowing. +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + + +/* + * Notes: wcstol should depend on the current locale's LC_NUMERIC category, + * this is not currently tested. + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR overstr[] = {'2','1','4','7','4','8','3','6','4','8',0}; + WCHAR understr[] = {'-','2','1','4','7','4','8','3','6','4','9',0}; + WCHAR *end; + LONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + errno = 0; + + l = wcstol(overstr, &end, 10); + + if (l != LONG_MAX) + { + Fail("ERROR: Expected wcstol to return %u, got %u\n", LONG_MAX, l); + } + if (end != overstr + 10) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + overstr + 10, end); + } + if (errno != ERANGE) + { + Fail("ERROR: wcstol did not set errno to ERANGE (%d)\n", errno); + } + + + errno = 0; + l = wcstol(understr, &end, 10); + + if (l != LONG_MIN) + { + Fail("ERROR: Expected wcstol to return %u, got %u\n", LONG_MIN, l); + } + if (end != understr + 11) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + understr + 11, end); + } + if (errno != ERANGE) + { + Fail("ERROR: wcstol did not set errno to ERANGE (%d)\n", errno); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test5/testinfo.dat new file mode 100644 index 0000000000..18b4478e3a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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 = wcstol +Name = Positive Test for wcstol +TYPE = DEFAULT +EXE1 = test5 +Description += Tests wcstol (base 10) with underflowing and overflowing. += Chesks that errno gets set to ERANGE. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test6/CMakeLists.txt new file mode 100644 index 0000000000..d328161f39 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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_wcstol_test6 + ${SOURCES} +) + +add_dependencies(paltest_wcstol_test6 coreclrpal) + +target_link_libraries(paltest_wcstol_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test6/test6.c b/src/pal/tests/palsuite/c_runtime/wcstol/test6/test6.c new file mode 100644 index 0000000000..14f6208231 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/test6/test6.c @@ -0,0 +1,86 @@ +// 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 wcstol function. Tests strings with octal/hex +** number specifers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + + +/* + * Notes: wcstol 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; + LONG l; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + l = wcstol(test1, &end, 16); + if (l != 0x12) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", 0x12, l); + } + if (end != test1 + 4) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + test1 + 4, end); + } + + l = wcstol(test1, &end, 10); + if (l != 0) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", 0, l); + } + if (end != test1+1) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + test1+1, end); + } + + l = wcstol(test2, &end, 8); + if (l != 10) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", 10, l); + } + if (end != test2 + 3) + { + Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", + test2 + 3, end); + } + + l = wcstol(test2, &end, 10); + if (l != 12) + { + Fail("ERROR: Expected wcstol to return %d, got %d\n", 12, l); + } + + if (end != test2 + 3) + { + Fail("ERROR: Expected wcstol 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/wcstol/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test6/testinfo.dat new file mode 100644 index 0000000000..0e10761e4d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/wcstol/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 = wcstol +Name = Positive Test for wcstol +TYPE = DEFAULT +EXE1 = test6 +Description += Tests wcstol with hex and octal strings, with different bases. |