summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/locale_info/GetLocaleInfoW
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/locale_info/GetLocaleInfoW')
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt5
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.c89
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/test2.c51
-rw-r--r--src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat14
7 files changed, 209 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt
new file mode 100644
index 0000000000..ef14ea5352
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test2)
+
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/CMakeLists.txt
new file mode 100644
index 0000000000..f373b98f7c
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/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_getlocaleinfow_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getlocaleinfow_test1 coreclrpal)
+
+target_link_libraries(paltest_getlocaleinfow_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.c b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.c
new file mode 100644
index 0000000000..0994940a57
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.c
@@ -0,0 +1,89 @@
+// 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 GetLocaleInfoW gives the correction information for
+** LOCALE_NEUTRAL.
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+
+int Types[] = { LOCALE_SDECIMAL, LOCALE_STHOUSAND, LOCALE_ILZERO,
+ LOCALE_SCURRENCY, LOCALE_SMONDECIMALSEP, LOCALE_SMONTHOUSANDSEP };
+
+char *TypeStrings[] = { "LOCALE_SDECIMAL", "LOCALE_STHOUSAND", "LOCALE_ILZERO",
+ "LOCALE_SCURRENCY", "LOCALE_SMONDECIMALSEP", "LOCALE_SMONTHOUSANDSEP" };
+
+#define NUM_TYPES (sizeof(Types) / sizeof(Types[0]))
+
+typedef WCHAR InfoStrings[NUM_TYPES][4];
+
+typedef struct
+{
+ LCID lcid;
+ InfoStrings Strings;
+} LocalInfoType;
+
+LocalInfoType Locales[] =
+{
+ {LOCALE_NEUTRAL,
+ {{'.',0}, {',',0}, {'1',0}, {'$',0}, {'.',0}, {',',0}}},
+};
+
+int NumLocales = sizeof(Locales) / sizeof(Locales[0]);
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ WCHAR buffer[256] = { 0 };
+ int ret;
+ int i,j;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ for (i=0; i<NumLocales; i++)
+ {
+ for (j=0; j<NUM_TYPES; j++)
+ {
+ ret = GetLocaleInfoW(Locales[i].lcid, Types[j], buffer, 256);
+
+ if (ret == 0)
+ {
+ Fail("GetLocaleInfoW returned an unexpected error!\n");
+ }
+
+
+ if (wcscmp(buffer, Locales[i].Strings[j]) != 0)
+ {
+
+ Fail("GetLocaleInfoW gave incorrect result for %s, "
+ "locale %#x:\nExpected \"%S\", got \"%S\"!\n", TypeStrings[j],
+ Locales[i].lcid, Locales[i].Strings[j], buffer);
+
+ }
+
+ if (ret != wcslen(Locales[i].Strings[j]) + 1)
+ {
+ Fail("GetLocaleInfoW returned incorrect value for %s, "
+ "locale %#x:\nExpected %d, got %d!\n", TypeStrings[j],
+ Locales[i].lcid, wcslen(Locales[i].Strings[j])+1, ret);
+ }
+ }
+ }
+
+
+ PAL_Terminate();
+
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/testinfo.dat
new file mode 100644
index 0000000000..00d974a71c
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/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 = Locale Information
+Function = GetLocaleInfoW
+Name = Test #1 for GetLocaleInfoW
+TYPE = DEFAULT
+EXE1 = test1
+Description
+=Tests that GetLocaleInfoW gives the correction information for LOCALE_NEUTRAL
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/CMakeLists.txt
new file mode 100644
index 0000000000..dd5b82ef61
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/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_getlocaleinfow_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_getlocaleinfow_test2 coreclrpal)
+
+target_link_libraries(paltest_getlocaleinfow_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/test2.c b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/test2.c
new file mode 100644
index 0000000000..f00fa79c59
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/test2.c
@@ -0,0 +1,51 @@
+// 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 GetLocaleInfoW will correctly return the amount of
+** buffer space required. Also tests that it correctly handles a
+** buffer of insufficient space.
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ WCHAR buffer[256] = { 0 };
+ int ret;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ ret = GetLocaleInfoW(LOCALE_NEUTRAL, LOCALE_SDECIMAL, buffer, 0);
+ if (ret != 2)
+ {
+ Fail("GetLocaleInfoW gave incorrect desired length for buffer.\n"
+ "Expected 2, got %d.\n", ret);
+ }
+
+ ret = GetLocaleInfoW(LOCALE_NEUTRAL, LOCALE_SDECIMAL, buffer, 1);
+ if (ret != 0)
+ {
+ Fail("GetLocaleInfoW expected to return 0, returned %d", ret);
+ }
+
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ {
+ Fail("GetLocaleInfoW failed to set last error to "
+ "ERROR_INSUFFICIENT_BUFFER!\n");
+ }
+
+ PAL_Terminate();
+
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat
new file mode 100644
index 0000000000..b9fc4886ee
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat
@@ -0,0 +1,14 @@
+# 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 = GetLocaleInfoW
+Name = Test #2 for GetLocaleInfoW
+TYPE = DEFAULT
+EXE1 = test2
+Description
+=Tests that GetLocaleInfoW will correctly return the amount of
+=buffer space required. Also tests that it correctly handles a
+=buffer of insufficient space.