summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/swscanf
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/swscanf')
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h262
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test1/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test1/test1.c53
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.c36
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test10/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.c35
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test11/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.c35
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test12/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.c37
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test13/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.c38
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test14/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.c37
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test15/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.c37
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test16/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.c37
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test17/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test2/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.c43
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test2/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test3/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.c36
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test3/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.c44
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test4/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.c44
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test5/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test6/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.c44
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test6/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.c44
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test7/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.c44
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test8/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.c37
-rw-r--r--src/pal/tests/palsuite/c_runtime/swscanf/test9/testinfo.dat12
53 files changed, 1490 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt
new file mode 100644
index 0000000000..59f39a5f58
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+add_subdirectory(test10)
+add_subdirectory(test11)
+add_subdirectory(test12)
+add_subdirectory(test13)
+add_subdirectory(test14)
+add_subdirectory(test15)
+add_subdirectory(test16)
+add_subdirectory(test17)
+add_subdirectory(test2)
+add_subdirectory(test3)
+add_subdirectory(test4)
+add_subdirectory(test5)
+add_subdirectory(test6)
+add_subdirectory(test7)
+add_subdirectory(test8)
+add_subdirectory(test9)
+
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h b/src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h
new file mode 100644
index 0000000000..1cac450cf4
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h
@@ -0,0 +1,262 @@
+// 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: swscanf.h
+**
+** Purpose: Contains common testing functions for swscanf.h
+**
+**
+**==========================================================================*/
+
+#ifndef __SWSCANF_H__
+#define __SWSCANF_H__
+
+void DoVoidTest(WCHAR *inputstr, WCHAR *formatstr)
+{
+ char buf[256] = { 0 };
+ int i;
+ int ret;
+
+ ret = swscanf(inputstr, formatstr, buf);
+ if (ret != 0)
+ {
+ Fail("ERROR: Expected sscanf to return 0, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ for (i=0; i<256; i++)
+ {
+ if (buf[i] != 0)
+ {
+ Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" "
+ "using \"%s\".\n", convertC(inputstr),
+ convertC(formatstr));
+ }
+ }
+
+}
+
+void DoStrTest(WCHAR *inputstr, WCHAR *formatstr, char *checkstr)
+{
+ char buf[256] = { 0 };
+ int ret;
+
+ ret = swscanf(inputstr, formatstr, buf);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n"
+ "Expected \"%s\", got \"%s\".\n", convertC(inputstr),
+ convertC(formatstr), checkstr,
+ buf);
+ }
+
+}
+
+void DoWStrTest(WCHAR *inputstr, WCHAR *formatstr, WCHAR *checkstr)
+{
+ WCHAR buf[256] = { 0 };
+ int ret;
+
+ ret = swscanf(inputstr, formatstr, buf);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (memcmp(checkstr, buf, wcslen(checkstr)*2 + 2) != 0)
+ {
+ Fail("ERROR: scanned wide string incorrectly from \"%s\" using \"%s\".\n"
+ "Expected \"%s\", got \"%s\".\n", convertC(inputstr),
+ convertC(formatstr), convertC(checkstr),
+ convertC(buf));
+ }
+
+}
+
+void DoNumTest(WCHAR *inputstr, WCHAR *formatstr, int checknum)
+{
+ int num = 0;
+ int ret;
+
+ ret = swscanf(inputstr, formatstr, &num);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (checknum != num)
+ {
+ Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n"
+ "Expected %d, got %d.\n", convertC(inputstr),
+ convertC(formatstr), checknum, num);
+ }
+}
+
+void DoShortNumTest(WCHAR *inputstr, WCHAR *formatstr, short checknum)
+{
+ short num = 0;
+ int ret;
+
+ ret = swscanf(inputstr, formatstr, &num);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (checknum != num)
+ {
+ Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n"
+ "Expected %hd, got %hd.\n", convertC(inputstr),
+ convertC(formatstr), checknum, num);
+ }
+}
+
+void DoI64NumTest(WCHAR *inputstr, WCHAR *formatstr, INT64 checknum)
+{
+ char buf[256];
+ char check[256];
+ INT64 num;
+ int ret;
+
+ ret = swscanf(inputstr, formatstr, &num);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (checknum != num)
+ {
+ sprintf(buf, "%I64d", num);
+ sprintf(check, "%I64d", checknum);
+ Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n"
+ "Expected %s, got %s.\n", convertC(inputstr),
+ convertC(formatstr), check, buf);
+ }
+}
+
+void DoCharTest(WCHAR *inputstr, WCHAR*formatstr, char* checkchars, int numchars)
+{
+ char buf[256];
+ int ret;
+ int i;
+
+ for (i=0; i<256; i++)
+ buf[i] = (char)-1;
+
+ ret = swscanf(inputstr, formatstr, buf);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (memcmp(buf, checkchars, numchars) != 0)
+ {
+ buf[numchars] = 0;
+
+ Fail("ERROR: scanned character(s) incorrectly from \"%s\" using \"%s\".\n"
+ "Expected %s, got %s.\n", convertC(inputstr),
+ convertC(formatstr), checkchars, buf);
+ }
+
+ if (buf[numchars] != (char)-1)
+ {
+ Fail("ERROR: overflow occurred in scanning character(s) from \"%s\" "
+ "using \"%s\".\nExpected %d character(s)\n",
+ convertC(inputstr), convertC(formatstr), numchars);
+ }
+}
+
+void DoWCharTest(WCHAR *inputstr, WCHAR *formatstr, WCHAR *checkchars, int numchars)
+{
+ WCHAR buf[256];
+ int ret;
+ int i;
+
+ for (i=0; i<256; i++)
+ buf[i] = (WCHAR)-1;
+
+ ret = swscanf(inputstr, formatstr, buf);
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (memcmp(buf, checkchars, numchars*2) != 0)
+ {
+ buf[numchars] = 0;
+
+ Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n"
+ "Expected %s, got %s.\n", convertC(inputstr),
+ convertC(formatstr), convertC(checkchars),
+ convertC(buf));
+ }
+
+ if (buf[numchars] != (WCHAR)-1)
+ {
+ Fail("ERROR: overflow occurred in scanning wide character(s) from \"%s\" "
+ "using \"%s\".\nExpected %d character(s)\n",
+ convertC(inputstr), convertC(formatstr), numchars);
+ }
+}
+
+
+void DoFloatTest(WCHAR *inputstr, WCHAR *formatstr, float checkval)
+{
+ char buf[256] = { 0 };
+ float val;
+ int ret;
+ int i;
+
+ for (i=0; i<256; i++)
+ buf[i] = (char)-1;
+
+ ret = swscanf(inputstr, formatstr, buf);
+ val = *(float*)buf;
+
+ if (ret != 1)
+ {
+ Fail("ERROR: Expected swscanf to return 1, got %d.\n"
+ "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr),
+ convertC(formatstr));
+ }
+
+ if (val != checkval)
+ {
+ Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n"
+ "Expected \"%f\", got \"%f\".\n", convertC(inputstr),
+ convertC(formatstr), checkval, val);
+ }
+
+ if (buf[4] != (char)-1)
+ {
+ Fail("ERROR: overflow occurred in scanning float from \"%s\" "
+ "using \"%s\".\n", convertC(inputstr), convertC(formatstr));
+
+ }
+}
+
+
+#endif
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test1/CMakeLists.txt
new file mode 100644
index 0000000000..030aaaf709
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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_swscanf_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test1 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test1
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/swscanf/test1/test1.c
new file mode 100644
index 0000000000..66136e57c5
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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: General test of swscanf
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int num;
+ int ret;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoVoidTest(convert("foo bar"), convert("foo"));
+ DoVoidTest(convert("foo bar"), convert("baz"));
+ DoVoidTest(convert("foo bar"), convert("foo %*s"));
+
+ DoStrTest(convert("foo % bar"), convert("foo %% %S"), "bar");
+ DoStrTest(convert("foo bar baz"), convert("foo %bar %S"), "baz");
+
+ DoVoidTest(convert("foo bar baz"), convert("foo % bar %S"));
+ DoVoidTest(convert("foo bar baz"), convert("foo% bar %S"));
+
+
+ ret = swscanf(convert("foo bar baz"), convert("foo bar %n"), &num);
+ if (ret != 0 || num != 8)
+ {
+ Fail("ERROR: Got incorrect values in scanning \"%s\" using \"%s\".\n"
+ "Expected to get a value of %d with return value of %d, "
+ "got %d with return %d\n", "foo bar baz", "foo bar %n", 8, 0,
+ num, ret);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test1/testinfo.dat
new file mode 100644
index 0000000000..b6366a73d0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= General test of swscanf
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt
new file mode 100644
index 0000000000..f7c8b284ff
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test10.c
+)
+
+add_executable(paltest_swscanf_test10
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test10 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test10
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.c b/src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.c
new file mode 100644
index 0000000000..a8628e0de1
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.c
@@ -0,0 +1,36 @@
+// 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: test10.c
+**
+** Purpose:Tests swscanf with wide characters
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoCharTest(convert("1234"), convert("%C"), "1", 1);
+ DoCharTest(convert("abc"), convert("%2C"), "ab", 2);
+ DoCharTest(convert(" ab"), convert("%C"), " ", 1);
+ DoCharTest(convert("ab"), convert("%hC"), "a", 1);
+ DoWCharTest(convert("ab"), convert("%lC"), convert("a"), 1);
+ DoCharTest(convert("ab"), convert("%LC"), "a", 1);
+ DoCharTest(convert("ab"), convert("%I64C"), "a", 1);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test10/testinfo.dat
new file mode 100644
index 0000000000..2f8890db20
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test10/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test10
+Description
+= Tests swscanf with wide characters
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt
new file mode 100644
index 0000000000..17066f31b8
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test11.c
+)
+
+add_executable(paltest_swscanf_test11
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test11 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test11
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.c b/src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.c
new file mode 100644
index 0000000000..f7eb4af46f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.c
@@ -0,0 +1,35 @@
+// 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: test11.c
+**
+** Purpose: Tests swscanf with strings
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoWStrTest(convert("foo bar"), convert("foo %s"), convert("bar"));
+ DoWStrTest(convert("foo bar"), convert("foo %2s"), convert("ba"));
+ DoStrTest(convert("foo bar"), convert("foo %hs"), "bar");
+ DoWStrTest(convert("foo bar"), convert("foo %ls"), convert("bar"));
+ DoWStrTest(convert("foo bar"), convert("foo %Ls"), convert("bar"));
+ DoWStrTest(convert("foo bar"), convert("foo %I64s"), convert("bar"));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test11/testinfo.dat
new file mode 100644
index 0000000000..5bbc2e433b
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test11/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test11
+Description
+= Tests swscanf with strings
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt
new file mode 100644
index 0000000000..95f5174ecb
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test12.c
+)
+
+add_executable(paltest_swscanf_test12
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test12 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test12
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.c b/src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.c
new file mode 100644
index 0000000000..f5f8bbdf8a
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.c
@@ -0,0 +1,35 @@
+// 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: test12.c
+**
+** Purpose: Tests swscanf with wide strings
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoStrTest(convert("foo bar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo bar"), convert("foo %2S"), "ba");
+ DoStrTest(convert("foo bar"), convert("foo %hS"), "bar");
+ DoWStrTest(convert("foo bar"), convert("foo %lS"), convert("bar"));
+ DoStrTest(convert("foo bar"), convert("foo %LS"), "bar");
+ DoStrTest(convert("foo bar"), convert("foo %I64S"), "bar");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test12/testinfo.dat
new file mode 100644
index 0000000000..06bf26af9b
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test12/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test12
+Description
+= Tests swscanf with wide strings
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt
new file mode 100644
index 0000000000..47abc50313
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test13.c
+)
+
+add_executable(paltest_swscanf_test13
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test13 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test13
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.c b/src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.c
new file mode 100644
index 0000000000..1bb0b7b21c
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.c
@@ -0,0 +1,37 @@
+// 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: test13.c
+**
+** Purpose: Tests swscanf with floats (decimal notation)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoFloatTest(convert("123.0"), convert("%f"), 123.0f);
+ DoFloatTest(convert("123.0"), convert("%2f"), 12.0f);
+ DoFloatTest(convert("10E1"), convert("%f"), 100.0f);
+ DoFloatTest(convert("-12.01e-2"), convert("%f"), -0.1201f);
+ DoFloatTest(convert("+12.01e-2"), convert("%f"), 0.1201f);
+ DoFloatTest(convert("-12.01e+2"), convert("%f"), -1201.0f);
+ DoFloatTest(convert("+12.01e+2"), convert("%f"), 1201.0f);
+ DoFloatTest(convert("1234567890.0123456789f"), convert("%f"), 1234567936);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test13/testinfo.dat
new file mode 100644
index 0000000000..a3c01c5d76
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test13/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test13
+Description
+= Tests swscanf with floats (decimal notation)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt
new file mode 100644
index 0000000000..a470436ce7
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test14.c
+)
+
+add_executable(paltest_swscanf_test14
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test14 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test14
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.c b/src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.c
new file mode 100644
index 0000000000..80581b726f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.c
@@ -0,0 +1,38 @@
+// 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: test14.c
+**
+** Purpose: Tests swscanf with floats (exponential notation, lowercase)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoFloatTest(convert("123.0"), convert("%e"), 123.0f);
+ DoFloatTest(convert("123.0"), convert("%2e"), 12.0f);
+ DoFloatTest(convert("10E1"), convert("%e"), 100.0f);
+ DoFloatTest(convert("-12.01e-2"), convert("%e"), -0.1201f);
+ DoFloatTest(convert("+12.01e-2"), convert("%e"), 0.1201f);
+ DoFloatTest(convert("-12.01e+2"), convert("%e"), -1201.0f);
+ DoFloatTest(convert("+12.01e+2"), convert("%e"), 1201.0f);
+ DoFloatTest(convert("1234567890.0123456789f"), convert("%e"), 1234567936);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test14/testinfo.dat
new file mode 100644
index 0000000000..184a3e7fb8
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test14/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test14
+Description
+= Tests swscanf with floats (exponential notation, lowercase)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt
new file mode 100644
index 0000000000..d89650b12c
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test15.c
+)
+
+add_executable(paltest_swscanf_test15
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test15 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test15
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.c b/src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.c
new file mode 100644
index 0000000000..9b7d277e17
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.c
@@ -0,0 +1,37 @@
+// 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: test15.c
+**
+** Purpose: Tests swscanf with floats (exponential notation, uppercase)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoFloatTest(convert("123.0"), convert("%E"), 123.0f);
+ DoFloatTest(convert("123.0"), convert("%2E"), 12.0f);
+ DoFloatTest(convert("10E1"), convert("%E"), 100.0f);
+ DoFloatTest(convert("-12.01e-2"), convert("%E"), -0.1201f);
+ DoFloatTest(convert("+12.01e-2"), convert("%E"), 0.1201f);
+ DoFloatTest(convert("-12.01e+2"), convert("%E"), -1201.0f);
+ DoFloatTest(convert("+12.01e+2"), convert("%E"), 1201.0f);
+ DoFloatTest(convert("1234567890.0123456789f"), convert("%E"), 1234567936);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test15/testinfo.dat
new file mode 100644
index 0000000000..ab20463ecd
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test15/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test15
+Description
+= Tests swscanf with floats (exponential notation, uppercase)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt
new file mode 100644
index 0000000000..a2a00f11b6
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test16.c
+)
+
+add_executable(paltest_swscanf_test16
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test16 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test16
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.c b/src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.c
new file mode 100644
index 0000000000..c83b64468b
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.c
@@ -0,0 +1,37 @@
+// 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: test16.c
+**
+** Purpose: Tests swscanf with floats (compact notation, lowercase)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoFloatTest(convert("123.0"), convert("%g"), 123.0f);
+ DoFloatTest(convert("123.0"), convert("%2g"), 12.0f);
+ DoFloatTest(convert("10E1"), convert("%g"), 100.0f);
+ DoFloatTest(convert("-12.01e-2"), convert("%g"), -0.1201f);
+ DoFloatTest(convert("+12.01e-2"), convert("%g"), 0.1201f);
+ DoFloatTest(convert("-12.01e+2"), convert("%g"), -1201.0f);
+ DoFloatTest(convert("+12.01e+2"), convert("%g"), 1201.0f);
+ DoFloatTest(convert("1234567890.0123456789f"), convert("%g"), 1234567936);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test16/testinfo.dat
new file mode 100644
index 0000000000..0cfa37d63b
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test16/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test16
+Description
+= Tests swscanf with floats (compact notation, lowercase)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt
new file mode 100644
index 0000000000..c224f5d9a6
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test17.c
+)
+
+add_executable(paltest_swscanf_test17
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test17 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test17
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.c b/src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.c
new file mode 100644
index 0000000000..9023f7020a
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.c
@@ -0,0 +1,37 @@
+// 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: test17.c
+**
+** Purpose: Tests swscanf with floats (compact notation, uppercase)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoFloatTest(convert("123.0"), convert("%G"), 123.0f);
+ DoFloatTest(convert("123.0"), convert("%2G"), 12.0f);
+ DoFloatTest(convert("10E1"), convert("%G"), 100.0f);
+ DoFloatTest(convert("-12.01e-2"), convert("%G"), -0.1201f);
+ DoFloatTest(convert("+12.01e-2"), convert("%G"), 0.1201f);
+ DoFloatTest(convert("-12.01e+2"), convert("%G"), -1201.0f);
+ DoFloatTest(convert("+12.01e+2"), convert("%G"), 1201.0f);
+ DoFloatTest(convert("1234567890.0123456789f"), convert("%G"), 1234567936);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test17/testinfo.dat
new file mode 100644
index 0000000000..f0489dfa41
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test17/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test17
+Description
+= Tests swscanf with floats (compact notation, uppercase)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test2/CMakeLists.txt
new file mode 100644
index 0000000000..a5335ddb48
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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_swscanf_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test2 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test2
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.c b/src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.c
new file mode 100644
index 0000000000..8fbd3f86ba
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.c
@@ -0,0 +1,43 @@
+// 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 to see if swscanf handles whitespace correctly
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+/*
+ * Tests out how it handles whitespace. Seems to accept anything that qualifies
+ * as isspace (space, tab, vertical tab, line feed, carriage return and form
+ * feed), even if it says it only wants spaces tabs and newlines.
+ */
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoStrTest(convert("foo bar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo\tbar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo\nbar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo\rbar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo\vbar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo\fbar"), convert("foo %S"), "bar");
+ DoStrTest(convert("foo \t\n\r\v\fbar"), convert("foo %S"), "bar");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test2/testinfo.dat
new file mode 100644
index 0000000000..88768ca465
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test2
+Description
+= Test to see if swscanf handles whitespace correctly
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test3/CMakeLists.txt
new file mode 100644
index 0000000000..5c229c26d3
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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_swscanf_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test3 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test3
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.c b/src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.c
new file mode 100644
index 0000000000..8b05df20f2
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.c
@@ -0,0 +1,36 @@
+// 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: Tests swscanf with bracketed set strings
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoWStrTest(convert("bar1"), convert("%[a-z]"), convert("bar"));
+ DoWStrTest(convert("bar1"), convert("%[z-a]"), convert("bar"));
+ DoWStrTest(convert("bar1"), convert("%[ab]"), convert("ba"));
+ DoWStrTest(convert("bar1"), convert("%[ar1b]"), convert("bar1"));
+ DoWStrTest(convert("bar1"), convert("%[^4]"), convert("bar1"));
+ DoWStrTest(convert("bar1"), convert("%[^4a]"), convert("b"));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test3/testinfo.dat
new file mode 100644
index 0000000000..998cba8b6b
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test3
+Description
+= Tests swscanf with bracketed set strings
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test4/CMakeLists.txt
new file mode 100644
index 0000000000..5e281aaf34
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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_swscanf_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test4 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test4
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.c b/src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.c
new file mode 100644
index 0000000000..d63d25b7d0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.c
@@ -0,0 +1,44 @@
+// 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:Tests swscanf with decimal numbers
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int n65535 = 65535; /* Walkaround compiler strictness */
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoNumTest(convert("1234d"), convert("%d"), 1234);
+ DoNumTest(convert("1234d"), convert("%2d"), 12);
+ DoNumTest(convert("-1"), convert("%d"), -1);
+ DoNumTest(convert("0x1234"), convert("%d"), 0);
+ DoNumTest(convert("012"), convert("%d"), 12);
+ DoShortNumTest(convert("-1"), convert("%hd"), n65535);
+ DoShortNumTest(convert("65536"), convert("%hd"), 0);
+ DoNumTest(convert("-1"), convert("%ld"), -1);
+ DoNumTest(convert("65536"), convert("%ld"), 65536);
+ DoNumTest(convert("-1"), convert("%Ld"), -1);
+ DoNumTest(convert("65536"), convert("%Ld"), 65536);
+ DoI64NumTest(convert("4294967296"), convert("%I64d"), I64(4294967296));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test4/testinfo.dat
new file mode 100644
index 0000000000..e6102872d7
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test4
+Description
+= Tests swscanf with decimal numbers
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test5/CMakeLists.txt
new file mode 100644
index 0000000000..8b259aa78d
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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_swscanf_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test5 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test5
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.c b/src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.c
new file mode 100644
index 0000000000..8ae2d81da6
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.c
@@ -0,0 +1,44 @@
+// 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: Tests swscanf with integer numbers
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int n65535 = 65535; /* Walkaround compiler strictness */
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoNumTest(convert("1234d"), convert("%i"), 1234);
+ DoNumTest(convert("1234d"), convert("%2i"), 12);
+ DoNumTest(convert("-1"), convert("%i"), -1);
+ DoNumTest(convert("0x1234"), convert("%i"), 0x1234);
+ DoNumTest(convert("012"), convert("%i"), 10);
+ DoShortNumTest(convert("-1"), convert("%hi"), n65535);
+ DoShortNumTest(convert("65536"), convert("%hi"), 0);
+ DoNumTest(convert("-1"), convert("%li"), -1);
+ DoNumTest(convert("65536"), convert("%li"), 65536);
+ DoNumTest(convert("-1"), convert("%Li"), -1);
+ DoNumTest(convert("65536"), convert("%Li"), 65536);
+ DoI64NumTest(convert("4294967296"), convert("%I64i"), I64(4294967296));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test5/testinfo.dat
new file mode 100644
index 0000000000..9991286402
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test5/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test5
+Description
+= Tests swscanf with integer numbers
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test6/CMakeLists.txt
new file mode 100644
index 0000000000..c3fd8696ab
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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_swscanf_test6
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test6 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test6
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.c b/src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.c
new file mode 100644
index 0000000000..982f799cfc
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.c
@@ -0,0 +1,44 @@
+// 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:Tests swscanf with octal numbers
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int n65535 = 65535; /* Walkaround compiler strictness */
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoNumTest(convert("1234d"), convert("%o"), 668);
+ DoNumTest(convert("1234d"), convert("%2o"), 10);
+ DoNumTest(convert("-1"), convert("%o"), -1);
+ DoNumTest(convert("0x1234"), convert("%o"), 0);
+ DoNumTest(convert("012"), convert("%o"), 10);
+ DoShortNumTest(convert("-1"), convert("%ho"), n65535);
+ DoShortNumTest(convert("200000"), convert("%ho"), 0);
+ DoNumTest(convert("-1"), convert("%lo"), -1);
+ DoNumTest(convert("200000"), convert("%lo"), 65536);
+ DoNumTest(convert("-1"), convert("%Lo"), -1);
+ DoNumTest(convert("200000"), convert("%Lo"), 65536);
+ DoI64NumTest(convert("40000000000"), convert("%I64o"), I64(4294967296));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test6/testinfo.dat
new file mode 100644
index 0000000000..ca7870e962
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test6
+Description
+= Tests swscanf with octal numbers
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt
new file mode 100644
index 0000000000..00541306df
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test7.c
+)
+
+add_executable(paltest_swscanf_test7
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test7 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test7
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.c b/src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.c
new file mode 100644
index 0000000000..45e9400549
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.c
@@ -0,0 +1,44 @@
+// 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: test7.c
+**
+** Purpose: Test #6 for the swscanf function
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int n65535 = 65535; /* Walkaround compiler strictness */
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoNumTest(convert("1234d"), convert("%x"), 0x1234d);
+ DoNumTest(convert("1234d"), convert("%2x"), 0x12);
+ DoNumTest(convert("-1"), convert("%x"), -1);
+ DoNumTest(convert("0x1234"), convert("%x"), 0x1234);
+ DoNumTest(convert("012"), convert("%x"), 0x12);
+ DoShortNumTest(convert("-1"), convert("%hx"), n65535);
+ DoShortNumTest(convert("10000"), convert("%hx"), 0);
+ DoNumTest(convert("-1"), convert("%lx"), -1);
+ DoNumTest(convert("10000"), convert("%lx"), 65536);
+ DoNumTest(convert("-1"), convert("%Lx"), -1);
+ DoNumTest(convert("10000"), convert("%Lx"), 65536);
+ DoI64NumTest(convert("100000000"), convert("%I64x"), I64(4294967296));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test7/testinfo.dat
new file mode 100644
index 0000000000..43ff8108df
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test7/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test7
+Description
+= Tests swscanf with hex numbers (lowercase)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt
new file mode 100644
index 0000000000..d6aa631ab9
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test8.c
+)
+
+add_executable(paltest_swscanf_test8
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test8 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test8
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.c b/src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.c
new file mode 100644
index 0000000000..a244de748f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.c
@@ -0,0 +1,44 @@
+// 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: test8.c
+**
+** Purpose: Tests swscanf with unsigned numbers
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int n65535 = 65535; /* Walkaround compiler strictness */
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoNumTest(convert("1234d"), convert("%u"), 1234);
+ DoNumTest(convert("1234d"), convert("%2u"), 12);
+ DoNumTest(convert("-1"), convert("%u"), -1);
+ DoNumTest(convert("0x1234"), convert("%u"), 0);
+ DoNumTest(convert("012"), convert("%u"), 12);
+ DoShortNumTest(convert("-1"), convert("%hu"), n65535);
+ DoShortNumTest(convert("65536"), convert("%hu"), 0);
+ DoNumTest(convert("-1"), convert("%lu"), -1);
+ DoNumTest(convert("65536"), convert("%lu"), 65536);
+ DoNumTest(convert("-1"), convert("%Lu"), -1);
+ DoNumTest(convert("65536"), convert("%Lu"), 65536);
+ DoI64NumTest(convert("4294967296"), convert("%I64u"), I64(4294967296));
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test8/testinfo.dat
new file mode 100644
index 0000000000..0edefb0756
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test8/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test8
+Description
+= Tests swscanf with unsigned numbers
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt
new file mode 100644
index 0000000000..4f7595a205
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test9.c
+)
+
+add_executable(paltest_swscanf_test9
+ ${SOURCES}
+)
+
+add_dependencies(paltest_swscanf_test9 coreclrpal)
+
+target_link_libraries(paltest_swscanf_test9
+ pthread
+ m
+ coreclrpal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.c b/src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.c
new file mode 100644
index 0000000000..e289d26f58
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.c
@@ -0,0 +1,37 @@
+// 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: test9.c
+**
+** Purpose: Tests swscanf with characters
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../swscanf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoWCharTest(convert("1234"), convert("%c"), convert("1"), 1);
+ DoWCharTest(convert("1234"), convert("%c"), convert("1"), 1);
+ DoWCharTest(convert("abc"), convert("%2c"), convert("ab"), 2);
+ DoWCharTest(convert(" ab"), convert("%c"), convert(" "), 1);
+ DoCharTest(convert("ab"), convert("%hc"), "a", 1);
+ DoWCharTest(convert("ab"), convert("%lc"), convert("a"), 1);
+ DoWCharTest(convert("ab"), convert("%Lc"), convert("a"), 1);
+ DoWCharTest(convert("ab"), convert("%I64c"), convert("a"), 1);
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test9/testinfo.dat
new file mode 100644
index 0000000000..955b62b12f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/swscanf/test9/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 = swscanf
+Name = Positive Test for swscanf
+TYPE = DEFAULT
+EXE1 = test9
+Description
+= Tests swscanf with characters