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/locale_info/GetCPInfo | |
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/locale_info/GetCPInfo')
10 files changed, 248 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/CMakeLists.txt new file mode 100644 index 0000000000..1962ade358 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test2) +add_subdirectory(test3) + diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/CMakeLists.txt new file mode 100644 index 0000000000..c209b121b2 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/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_getcpinfo_test1 + ${SOURCES} +) + +add_dependencies(paltest_getcpinfo_test1 coreclrpal) + +target_link_libraries(paltest_getcpinfo_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/test1.c b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/test1.c new file mode 100644 index 0000000000..ed9bbf93fc --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/test1.c @@ -0,0 +1,54 @@ +// 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 that GetCPInfo works for CP_ACP and 0x4E4 (default codepage) +** Also makes sure it correctly handles an invalid code page. +** +** +**==========================================================================*/ + + +#include <palsuite.h> + + +int __cdecl main(int argc, char *argv[]) +{ + CPINFO cpinfo; + + if (0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + if (!GetCPInfo(CP_ACP, &cpinfo)) + { + Fail("GetCPInfo() unable to get info for CP_ACP\n"); + } + + if (!GetCPInfo(65001, &cpinfo)) + { + Fail("GetCPInfo() unable to get info for code page 65001 (utf8)\n"); + } + + if (GetCPInfo(-1, &cpinfo)) + { + Fail("GetCPInfo() did not error on invalid code page!\n"); + } + + if (GetLastError() != ERROR_INVALID_PARAMETER) + { + Fail("GetCPInfo() failed to set the last error to" + " ERROR_INVALID_PARAMETER!\n"); + } + + + PAL_Terminate(); + + return PASS; +} + diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/testinfo.dat new file mode 100644 index 0000000000..31be1d5536 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/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 = Locale Information +Function = GetCPInfo +Name = Test #1 for GetCPInfo +TYPE = DEFAULT +EXE1 = test1 +Description +=Tests that GetCPInfo works for CP_ACP and 0x4E4 (default codepage) +=Also makes sure it correctly handles an invalid code page. diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/CMakeLists.txt new file mode 100644 index 0000000000..6132e9b3fa --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/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_getcpinfo_test2 + ${SOURCES} +) + +add_dependencies(paltest_getcpinfo_test2 coreclrpal) + +target_link_libraries(paltest_getcpinfo_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/test2.c b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/test2.c new file mode 100644 index 0000000000..f52320f167 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/test2.c @@ -0,0 +1,60 @@ +// 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: Tests that GetCPInfo gives the correct information for codepage 0x4E4 +** (the default). +** +** +**==========================================================================*/ + + +#include <palsuite.h> + + +int __cdecl main(int argc, char *argv[]) +{ + CPINFO cpinfo; + int codepage; + unsigned int i; + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + /* + * codepage 1252 (0x4E4): Windows 3.1 Latin 1 (U.S., Western Europe) + */ + codepage = 1252; + + if (!GetCPInfo(codepage, &cpinfo)) + { + Fail("GetCPInfo() failed on default ansi code page!\n"); + } + if (cpinfo.MaxCharSize != 1) + { + Fail("GetCPInfo() returned incorrect MaxCharSize information!\n"); + } + if (cpinfo.DefaultChar[0] != '?' || cpinfo.DefaultChar[1] != 0) + { + Fail("GetCPInfo() returned incorrect DefaultChar information"); + } + + for (i = 0; i<MAX_LEADBYTES; i++) + { + if (cpinfo.LeadByte[i] != 0) + { + Fail("GetCPInfo() returned incorrect LeadByte information"); + } + } + + PAL_Terminate(); + + return PASS; +} + diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/testinfo.dat new file mode 100644 index 0000000000..fee6849858 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/testinfo.dat @@ -0,0 +1,9 @@ +Version = 1.0 +Section = Locale Information +Function = GetCPInfo +Name = Test #2 for GetCPInfo +TYPE = DEFAULT +EXE1 = test2 +Description +=Tests that GetCPInfo gives the correct information for codepage 0x4E4 +=(the default). diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/CMakeLists.txt new file mode 100644 index 0000000000..3e4a09b51d --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/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_getcpinfo_test3 + ${SOURCES} +) + +add_dependencies(paltest_getcpinfo_test3 coreclrpal) + +target_link_libraries(paltest_getcpinfo_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/test3.c b/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/test3.c new file mode 100644 index 0000000000..aa9df935b8 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/test3.c @@ -0,0 +1,41 @@ +// 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 that passes CP_ACP to GetCPInfo, verifying the results. +** +** +**==========================================================================*/ + +#include <palsuite.h> + +/* Currently only one CodePage "CP_ACP" is supported by the PAL */ + +int __cdecl main(int argc, char *argv[]) +{ + CPINFO cpinfo; + + /* Initialize the PAL. + */ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + /* Test GetCPInfo with CP_ACP. + */ + if (!GetCPInfo(CP_ACP, &cpinfo)) + { + Fail("GetCPInfo() unable to get info for code page %d!\n", CP_ACP); + } + + /* Terminate the PAL. + */ + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/testinfo.dat new file mode 100644 index 0000000000..13f7a29262 --- /dev/null +++ b/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/testinfo.dat @@ -0,0 +1,8 @@ +Version = 1.0 +Section = Locale Information +Function = GetCPInfo +Name = Test #3 for GetCPInfo +TYPE = DEFAULT +EXE1 = test3 +Description +=Tests that GetCPInfo passes for all valid code pages |