diff options
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/sscanf_s')
53 files changed, 1470 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/CMakeLists.txt new file mode 100644 index 0000000000..59f39a5f58 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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/sscanf_s/sscanf_s.h b/src/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h new file mode 100644 index 0000000000..8a99d87cb4 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h @@ -0,0 +1,246 @@ +// 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: sscanf_s.h +** +** Purpose: Contains common testing functions for sscanf_s +** +** +**==========================================================================*/ + +#ifndef __SSCANF_S_H__ +#define __SSCANF_S_H__ + +void DoVoidTest(char *inputstr, const char *formatstr) +{ + char buf[256] = { 0 }; + int i; + int ret; + + ret = sscanf_s(inputstr, formatstr, buf); + if (ret != 0) + { + Fail("ERROR: Expected sscanf_s to return 0, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + for (i=0; i<256; i++) + { + if (buf[i] != 0) + { + Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" " + "using \"%s\".\n", inputstr, formatstr); + } + } + +} + +void DoStrTest(char *inputstr, const char *formatstr, const char *checkstr) +{ + char buf[256] = { 0 }; + int ret; + + ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0) + { + Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n" + "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, checkstr, + buf); + } + +} + +void DoWStrTest(char *inputstr, const char *formatstr, const WCHAR *checkstr) +{ + WCHAR buf[256] = { 0 }; + int ret; + + ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, 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", inputstr, formatstr, + convertC(checkstr), convertC(buf)); + } + +} + +void DoNumTest(char *inputstr, const char *formatstr, int checknum) +{ + int num; + int ret; + + ret = sscanf_s(inputstr, formatstr, &num); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + if (checknum != num) + { + Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" + "Expected %d, got %d.\n", inputstr, formatstr, checknum, num); + } +} + +void DoShortNumTest(char *inputstr, const char *formatstr, short checknum) +{ + short num; + int ret; + + ret = sscanf_s(inputstr, formatstr, &num); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + if (checknum != num) + { + Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" + "Expected %hd, got %hd.\n", inputstr, formatstr, checknum, num); + } +} + +void DoI64NumTest(char *inputstr, const char *formatstr, INT64 checknum) +{ + char buf[256]; + char check[256]; + INT64 num; + int ret; + + ret = sscanf_s(inputstr, formatstr, &num); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + if (checknum != num) + { + sprintf_s(buf, _countof(buf), "%I64d", num); + sprintf_s(check, _countof(check), "%I64d", checknum); + Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n" + "Expected %s, got %s.\n", inputstr, formatstr, check, buf); + } +} + +void DoCharTest(char *inputstr, const char *formatstr, char* checkchars, int numchars) +{ + char buf[256]; + int ret; + int i; + + for (i=0; i<256; i++) + buf[i] = (char)-1; + + ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, 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", inputstr, 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", inputstr, formatstr, + numchars); + } +} + +void DoWCharTest(char *inputstr, const char *formatstr, WCHAR* checkchars, int numchars) +{ + WCHAR buf[256]; + int ret; + int i; + + for (i=0; i<256; i++) + buf[i] = (WCHAR)-1; + + ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + if (memcmp(buf, checkchars, numchars) != 0) + { + buf[numchars] = 0; + + Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n" + "Expected %s, got %s.\n", inputstr, 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", inputstr, formatstr, + numchars); + } +} + + +void DoFloatTest(char *inputstr, const char *formatstr, float checkval) +{ + char buf[256] = { 0 }; + float val; + int ret; + int i; + + for (i=0; i<256; i++) + buf[i] = (char)-1; + + ret = sscanf_s(inputstr, formatstr, buf); + val = *(float*)buf; + + if (ret != 1) + { + Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" + "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); + } + + if (val != checkval) + { + Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n" + "Expected \"%f\", got \"%f\".\n", inputstr, formatstr, checkval, + val); + } + + if (buf[4] != (char)-1) + { + Fail("ERROR: overflow occurred in scanning float from \"%s\" " + "using \"%s\".\n", inputstr, formatstr); + + } +} + + +#endif diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/CMakeLists.txt new file mode 100644 index 0000000000..97b8f570e3 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test1.cpp +) + +add_executable(paltest_sscanf_test1 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test1 coreclrpal) + +target_link_libraries(paltest_sscanf_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/test1.cpp new file mode 100644 index 0000000000..61313146e5 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/test1.cpp @@ -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 sscanf_s +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + + +int __cdecl main(int argc, char *argv[]) +{ + int num; + int ret; + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + DoVoidTest("foo bar", "foo "); + DoVoidTest("foo bar", "baz"); + DoVoidTest("foo bar", "foo %*s"); + + DoStrTest("foo % bar", "foo %% %s", "bar"); + DoStrTest("foo bar baz", "foo %bar %s", "baz"); + + DoVoidTest("foo bar baz", "foo % bar %s"); + DoVoidTest("foo baz bar", "foo% baz %s"); + + ret = sscanf_s("foo bar baz", "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/sscanf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/testinfo.dat new file mode 100644 index 0000000000..76f592769f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test1 +Description += General test of sscanf_s diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/CMakeLists.txt new file mode 100644 index 0000000000..afda216c6b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test10.cpp +) + +add_executable(paltest_sscanf_test10 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test10 coreclrpal) + +target_link_libraries(paltest_sscanf_test10 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp new file mode 100644 index 0000000000..0c63c864ed --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp @@ -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: test10.c +** +** Purpose: Tests sscanf_s with wide characters +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoWCharTest("1234d", "%C", convert("1"), 1); + DoWCharTest("1234d", "%C", convert("1"), 1); + DoWCharTest("abc", "%2C", convert("ab"), 2); + DoWCharTest(" ab", "%C", convert(" "), 1); + DoCharTest("ab", "%hC", "a", 1); + DoWCharTest("ab", "%lC", convert("a"), 1); + DoWCharTest("ab", "%LC", convert("a"), 1); + DoWCharTest("ab", "%I64C", convert("a"), 1); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/testinfo.dat new file mode 100644 index 0000000000..e048e700a0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test10 +Description += Tests sscanf_s with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/CMakeLists.txt new file mode 100644 index 0000000000..c8f98aeeef --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test11.cpp +) + +add_executable(paltest_sscanf_test11 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test11 coreclrpal) + +target_link_libraries(paltest_sscanf_test11 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/test11.cpp new file mode 100644 index 0000000000..8279f4b3f4 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/test11.cpp @@ -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: test11.c +** +** Purpose: Tests sscanf_s with strings +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoStrTest("foo bar", "foo %s", "bar"); + DoStrTest("foo bar", "foo %2s", "ba"); + DoStrTest("foo bar", "foo %hs", "bar"); + DoWStrTest("foo bar", "foo %ls", convert("bar")); + DoStrTest("foo bar", "foo %Ls", "bar"); + DoStrTest("foo bar", "foo %I64s", "bar"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/testinfo.dat new file mode 100644 index 0000000000..5a906ddf51 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test11 +Description += Tests sscanf_s with strings diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/CMakeLists.txt new file mode 100644 index 0000000000..0ecedc3285 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test12.cpp +) + +add_executable(paltest_sscanf_test12 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test12 coreclrpal) + +target_link_libraries(paltest_sscanf_test12 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/test12.cpp new file mode 100644 index 0000000000..e599534270 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/test12.cpp @@ -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 sscanf_s with wide strings +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoWStrTest("foo bar", "foo %S", convert("bar")); + DoWStrTest("foo bar", "foo %2S", convert("ba")); + DoStrTest("foo bar", "foo %hS", "bar"); + DoWStrTest("foo bar", "foo %lS", convert("bar")); + DoWStrTest("foo bar", "foo %LS", convert("bar")); + DoWStrTest("foo bar", "foo %I64S", convert("bar")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/testinfo.dat new file mode 100644 index 0000000000..569be983c0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test12 +Description += Tests sscanf_s with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/CMakeLists.txt new file mode 100644 index 0000000000..4566ec3338 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test13.cpp +) + +add_executable(paltest_sscanf_test13 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test13 coreclrpal) + +target_link_libraries(paltest_sscanf_test13 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/test13.cpp new file mode 100644 index 0000000000..4fc12bb751 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/test13.cpp @@ -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 sscanf_s with floats (decimal notation) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoFloatTest("123.0", "%f", 123.0f); + DoFloatTest("123.0", "%2f", 12.0f); + DoFloatTest("10E1", "%f", 100.0f); + DoFloatTest("-12.01e-2", "%f", -0.1201f); + DoFloatTest("+12.01e-2", "%f", 0.1201f); + DoFloatTest("-12.01e+2", "%f", -1201.0f); + DoFloatTest("+12.01e+2", "%f", 1201.0f); + DoFloatTest("1234567890.0123456789f", "%f", 1234567936); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/testinfo.dat new file mode 100644 index 0000000000..651577befd --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test13 +Description += Tests sscanf_s with floats (decimal notation) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/CMakeLists.txt new file mode 100644 index 0000000000..557acf5bf8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test14.cpp +) + +add_executable(paltest_sscanf_test14 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test14 coreclrpal) + +target_link_libraries(paltest_sscanf_test14 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/test14.cpp new file mode 100644 index 0000000000..fc2fa2ee15 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/test14.cpp @@ -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: test14.c +** +** Purpose: Tests sscanf_s with floats (exponential notation, lowercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoFloatTest("123.0", "%e", 123.0f); + DoFloatTest("123.0", "%2e", 12.0f); + DoFloatTest("10E1", "%e", 100.0f); + DoFloatTest("-12.01e-2", "%e", -0.1201f); + DoFloatTest("+12.01e-2", "%e", 0.1201f); + DoFloatTest("-12.01e+2", "%e", -1201.0f); + DoFloatTest("+12.01e+2", "%e", 1201.0f); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/testinfo.dat new file mode 100644 index 0000000000..8e7338fd46 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test14 +Description += Tests sscanf_s with floats (exponential notation, lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/CMakeLists.txt new file mode 100644 index 0000000000..efde5c4a21 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test15.cpp +) + +add_executable(paltest_sscanf_test15 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test15 coreclrpal) + +target_link_libraries(paltest_sscanf_test15 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/test15.cpp new file mode 100644 index 0000000000..1eff995b86 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/test15.cpp @@ -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: test15.c +** +** Purpose: Tests sscanf_s with floats (exponential notation, uppercase +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoFloatTest("123.0", "%E", 123.0f); + DoFloatTest("123.0", "%2E", 12.0f); + DoFloatTest("10E1", "%E", 100.0f); + DoFloatTest("-12.01e-2", "%E", -0.1201f); + DoFloatTest("+12.01e-2", "%E", 0.1201f); + DoFloatTest("-12.01e+2", "%E", -1201.0f); + DoFloatTest("+12.01e+2", "%E", 1201.0f); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/testinfo.dat new file mode 100644 index 0000000000..d713a73d81 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test15 +Description += Tests sscanf_s with floats (exponential notation, uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/CMakeLists.txt new file mode 100644 index 0000000000..6757b0d78a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test16.cpp +) + +add_executable(paltest_sscanf_test16 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test16 coreclrpal) + +target_link_libraries(paltest_sscanf_test16 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/test16.cpp new file mode 100644 index 0000000000..f202767448 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/test16.cpp @@ -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 sscanf_s with floats (compact notation, lowercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoFloatTest("123.0", "%g", 123.0f); + DoFloatTest("123.0", "%2g", 12.0f); + DoFloatTest("10E1", "%g", 100.0f); + DoFloatTest("-12.01e-2", "%g", -0.1201f); + DoFloatTest("+12.01e-2", "%g", 0.1201f); + DoFloatTest("-12.01e+2", "%g", -1201.0f); + DoFloatTest("+12.01e+2", "%g", 1201.0f); + DoFloatTest("1234567890.0123456789g", "%g", 1234567936); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/testinfo.dat new file mode 100644 index 0000000000..669611945d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test16 +Description += Tests sscanf_s with floats (compact notation, lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/CMakeLists.txt new file mode 100644 index 0000000000..8ea4d5e3f6 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test17.cpp +) + +add_executable(paltest_sscanf_test17 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test17 coreclrpal) + +target_link_libraries(paltest_sscanf_test17 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/test17.cpp new file mode 100644 index 0000000000..a18c3caff1 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/test17.cpp @@ -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 sscanf_s with floats (compact notation, uppercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoFloatTest("123.0", "%G", 123.0f); + DoFloatTest("123.0", "%2G", 12.0f); + DoFloatTest("10E1", "%G", 100.0f); + DoFloatTest("-12.01e-2", "%G", -0.1201f); + DoFloatTest("+12.01e-2", "%G", 0.1201f); + DoFloatTest("-12.01e+2", "%G", -1201.0f); + DoFloatTest("+12.01e+2", "%G", 1201.0f); + DoFloatTest("1234567890.0123456789G", "%G", 1234567936); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/testinfo.dat new file mode 100644 index 0000000000..8ce4e93e1a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test17 +Description += Tests sscanf_s with floats (compact notation, uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/CMakeLists.txt new file mode 100644 index 0000000000..4e36223a1d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test2.cpp +) + +add_executable(paltest_sscanf_test2 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test2 coreclrpal) + +target_link_libraries(paltest_sscanf_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/test2.cpp new file mode 100644 index 0000000000..c9c79f67ea --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/test2.cpp @@ -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: test2.c +** +** Purpose: Test to see if sscanf_s handles whitespace correctly +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.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("foo bar", "foo %s", "bar"); + DoStrTest("foo\tbar", "foo %s", "bar"); + DoStrTest("foo\nbar", "foo %s", "bar"); + DoStrTest("foo\rbar", "foo %s", "bar"); + DoStrTest("foo\vbar", "foo %s", "bar"); + DoStrTest("foo\fbar", "foo %s", "bar"); + DoStrTest("foo \t\n\r\v\fbar", "foo %s", "bar"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/testinfo.dat new file mode 100644 index 0000000000..85fed244f9 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test2 +Description += Test to see if sscanf_s handles whitespace correctly diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/CMakeLists.txt new file mode 100644 index 0000000000..053a96ca0f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test3.cpp +) + +add_executable(paltest_sscanf_test3 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test3 coreclrpal) + +target_link_libraries(paltest_sscanf_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/test3.cpp new file mode 100644 index 0000000000..e1e45bdd70 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/test3.cpp @@ -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: test3.c +** +** Purpose: Tests sscanf_s with bracketed set strings +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoStrTest("bar1", "%[a-z]", "bar"); + DoStrTest("bar1", "%[z-a]", "bar"); + DoStrTest("bar1", "%[ab]", "ba"); + DoStrTest("bar1", "%[ar1b]", "bar1"); + DoStrTest("bar1", "%[^4]", "bar1"); + DoStrTest("bar1", "%[^4a]", "b"); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/testinfo.dat new file mode 100644 index 0000000000..523d31e82e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test3 +Description += Tests sscanf_s with bracketed set strings diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/CMakeLists.txt new file mode 100644 index 0000000000..ae04bfef57 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test4.cpp +) + +add_executable(paltest_sscanf_test4 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test4 coreclrpal) + +target_link_libraries(paltest_sscanf_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/test4.cpp new file mode 100644 index 0000000000..f8413ea7fd --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/test4.cpp @@ -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 sscanf_s with decimal numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + + +int __cdecl main(int argc, char *argv[]) +{ + int n65535 = 65535; /* Walkaround compiler strictness */ + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoNumTest("1234d", "%d", 1234); + DoNumTest("1234d", "%2d", 12); + DoNumTest("-1", "%d", -1); + DoNumTest("0x1234", "%d", 0); + DoNumTest("012", "%d", 12); + DoShortNumTest("-1", "%hd", n65535); + DoShortNumTest("65536", "%hd", 0); + DoNumTest("-1", "%ld", -1); + DoNumTest("65536", "%ld", 65536); + DoNumTest("-1", "%Ld", -1); + DoNumTest("65536", "%Ld", 65536); + DoI64NumTest("4294967296", "%I64d", I64(4294967296)); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/testinfo.dat new file mode 100644 index 0000000000..2065f2bea2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test4 +Description += Tests sscanf_s with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/CMakeLists.txt new file mode 100644 index 0000000000..33dcaffec3 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test5.cpp +) + +add_executable(paltest_sscanf_test5 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test5 coreclrpal) + +target_link_libraries(paltest_sscanf_test5 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/test5.cpp new file mode 100644 index 0000000000..cdfefd860b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/test5.cpp @@ -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: test5.c +** +** Purpose: Tests sscanf_s with integer numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + int n65535 = 65535; /* Walkaround compiler strictness */ + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoNumTest("1234d", "%i", 1234); + DoNumTest("1234d", "%2i", 12); + DoNumTest("-1", "%i", -1); + DoNumTest("0x1234", "%i", 0x1234); + DoNumTest("012", "%i", 10); + DoShortNumTest("-1", "%hi", n65535); + DoShortNumTest("65536", "%hi", 0); + DoNumTest("-1", "%li", -1); + DoNumTest("65536", "%li", 65536); + DoNumTest("-1", "%Li", -1); + DoNumTest("65536", "%Li", 65536); + DoI64NumTest("4294967296", "%I64i", I64(4294967296)); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/testinfo.dat new file mode 100644 index 0000000000..cb687c15cd --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test5 +Description += Tests sscanf_s with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/CMakeLists.txt new file mode 100644 index 0000000000..1dd23c3cb1 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test6.cpp +) + +add_executable(paltest_sscanf_test6 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test6 coreclrpal) + +target_link_libraries(paltest_sscanf_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/test6.cpp new file mode 100644 index 0000000000..507b100e15 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/test6.cpp @@ -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: test6.c +** +** Purpose: Tests sscanf_s with octal numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + int n65535 = 65535; /* Walkaround compiler strictness */ + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoNumTest("1234d", "%o", 668); + DoNumTest("1234d", "%2o", 10); + DoNumTest("-1", "%o", -1); + DoNumTest("0x1234", "%o", 0); + DoNumTest("012", "%o", 10); + DoShortNumTest("-1", "%ho", n65535); + DoShortNumTest("200000", "%ho", 0); + DoNumTest("-1", "%lo", -1); + DoNumTest("200000", "%lo", 65536); + DoNumTest("-1", "%Lo", -1); + DoNumTest("200000", "%Lo", 65536); + DoI64NumTest("40000000000", "%I64o", I64(4294967296)); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/testinfo.dat new file mode 100644 index 0000000000..9e518dddf2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test6 +Description += Tests sscanf_s with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/CMakeLists.txt new file mode 100644 index 0000000000..015a27b776 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test7.cpp +) + +add_executable(paltest_sscanf_test7 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test7 coreclrpal) + +target_link_libraries(paltest_sscanf_test7 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/test7.cpp new file mode 100644 index 0000000000..4093e009e1 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/test7.cpp @@ -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: test7.c +** +** Purpose: Tests sscanf_s with hex numbers (lowercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + int n65535 = 65535; /* Walkaround compiler strictness */ + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoNumTest("1234i", "%x", 0x1234); + DoNumTest("1234i", "%2x", 0x12); + DoNumTest("-1", "%x", -1); + DoNumTest("0x1234", "%x", 0x1234); + DoNumTest("012", "%x", 0x12); + DoShortNumTest("-1", "%hx", n65535); + DoShortNumTest("10000", "%hx", 0); + DoNumTest("-1", "%lx", -1); + DoNumTest("10000", "%lx", 65536); + DoNumTest("-1", "%Lx", -1); + DoNumTest("10000", "%Lx", 65536); + DoI64NumTest("100000000", "%I64x", I64(4294967296)); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/testinfo.dat new file mode 100644 index 0000000000..8d6c182c90 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test7 +Description += Tests sscanf_s with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/CMakeLists.txt new file mode 100644 index 0000000000..aa41ab42a6 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test8.cpp +) + +add_executable(paltest_sscanf_test8 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test8 coreclrpal) + +target_link_libraries(paltest_sscanf_test8 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/test8.cpp new file mode 100644 index 0000000000..23ef22a56a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/test8.cpp @@ -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: test8.c +** +** Purpose:Tests sscanf_s with unsigned number +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + +int __cdecl main(int argc, char *argv[]) +{ + int n65535 = 65535; /* Walkaround compiler strictness */ + + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoNumTest("1234d", "%u", 1234); + DoNumTest("1234d", "%2u", 12); + DoNumTest("-1", "%u", -1); + DoNumTest("0x1234", "%u", 0); + DoNumTest("012", "%u", 12); + DoShortNumTest("-1", "%hu", n65535); + DoShortNumTest("65536", "%hu", 0); + DoNumTest("-1", "%lu", -1); + DoNumTest("65536", "%lu", 65536); + DoNumTest("-1", "%Lu", -1); + DoNumTest("65536", "%Lu", 65536); + DoI64NumTest("4294967296", "%I64u", I64(4294967296)); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/testinfo.dat new file mode 100644 index 0000000000..0287a495d2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test8 +Description += Tests sscanf_s with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/CMakeLists.txt new file mode 100644 index 0000000000..b631fd40ea --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test9.cpp +) + +add_executable(paltest_sscanf_test9 + ${SOURCES} +) + +add_dependencies(paltest_sscanf_test9 coreclrpal) + +target_link_libraries(paltest_sscanf_test9 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/test9.cpp new file mode 100644 index 0000000000..2c99c40e5d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/test9.cpp @@ -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: test9.c +** +** Purpose: Tests sscanf_s with characters +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../sscanf_s.h" + + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv)) + { + return FAIL; + } + + DoCharTest("1234d", "%c", "1", 1); + DoCharTest("1234d", "%c", "1", 1); + DoCharTest("abc", "%2c", "ab", 2); + DoCharTest(" ab", "%c", " ", 1); + DoCharTest("ab", "%hc", "a", 1); + DoWCharTest("ab", "%lc", convert("a"), 1); + DoCharTest("ab", "%Lc", "a", 1); + DoCharTest("ab", "%I64c", "a", 1); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/testinfo.dat new file mode 100644 index 0000000000..95f6c74ee2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/sscanf_s/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 = sscanf_s +Name = Positive Test for sscanf_s +TYPE = DEFAULT +EXE1 = test9 +Description += Tests sscanf_s with characters |