diff options
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/swprintf')
59 files changed, 1958 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt new file mode 100644 index 0000000000..cafb9536b0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/CMakeLists.txt @@ -0,0 +1,22 @@ +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(test18) +add_subdirectory(test19) +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/swprintf/swprintf.h b/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h new file mode 100644 index 0000000000..5229506064 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/swprintf.h @@ -0,0 +1,202 @@ +// 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: swprintf.h +** +** Purpose: Containts common testing functions for swprintf.h +** +** +**==========================================================================*/ + +#ifndef __SWPRINTF_H__ +#define __SWPRINTF_H__ + +void DoWStrTest(WCHAR *formatstr, WCHAR *param, WCHAR *checkstr) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, param); + + if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) + { + Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" + "Expected \"%s\", got \"%s\".\n", + convertC(param), convertC(formatstr), + convertC(checkstr), convertC(buf)); + } +} + +void DoStrTest(WCHAR *formatstr, char *param, WCHAR *checkstr) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, param); + + if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) + { + Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" + "Expected \"%s\", got \"%s\".\n", + param, convertC(formatstr), convertC(checkstr), + convertC(buf)); + } +} + +void DoPointerTest(WCHAR *formatstr, void* param, WCHAR *checkstr1) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, param); + if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) + { + Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" + "Expected \"%s\", got \"%s\".\n", param, + convertC(formatstr), convertC(checkstr1), convertC(buf)); + } +} + +void DoCountTest(WCHAR *formatstr, int param, WCHAR *checkstr) +{ + WCHAR buf[512] = { 0 }; + int n = -1; + + swprintf(buf, formatstr, &n); + + if (n != param) + { + Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", + param, n); + } + + if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) + { + Fail("ERROR: Expected \"%s\" got \"%s\".\n", + convertC(checkstr), convertC(buf)); + } +} + +void DoShortCountTest(WCHAR *formatstr, int param, WCHAR *checkstr) +{ + WCHAR buf[256] = { 0 }; + short int n = -1; + + swprintf(buf, formatstr, &n); + + if (n != param) + { + Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", + param, n); + } + + if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) + { + Fail("ERROR: Expected \"%s\" got \"%s\".\n", + convertC(checkstr), convertC(buf)); + } +} + +void DoCharTest(WCHAR *formatstr, char param, WCHAR *checkstr) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, param); + if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) + { + Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", param, param, + convertC(formatstr), convertC(checkstr), convertC(buf)); + } +} + +void DoWCharTest(WCHAR *formatstr, WCHAR param, WCHAR *checkstr) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, param); + if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) + { + Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", (char) param, param, + convertC(formatstr), convertC(checkstr), convertC(buf)); + } +} + +void DoNumTest(WCHAR *formatstr, int value, WCHAR*checkstr) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, value); + if (memcmp(buf, checkstr, wcslen(checkstr)* 2 + 2) != 0) + { + Fail("ERROR: failed to insert %#x into \"%s\"\n" + "Expected \"%s\" got \"%s\".\n", value, convertC(formatstr), + convertC(checkstr), convertC(buf)); + } +} + +void DoI64Test(WCHAR *formatstr, INT64 param, char *paramdesc, + WCHAR *checkstr1) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, param); + if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) + { + Fail("ERROR: failed to insert %s into \"%s\"\n" + "Expected \"%s\", got \"%s\".\n", paramdesc, + convertC(formatstr), convertC(checkstr1), convertC(buf)); + } +} + +void DoDoubleTest(WCHAR *formatstr, double value, WCHAR *checkstr1, + WCHAR *checkstr2) +{ + WCHAR buf[256] = { 0 }; + + swprintf(buf, formatstr, value); + if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0 && + memcmp(buf, checkstr2, wcslen(checkstr2)*2 + 2) != 0) + { + Fail("ERROR: failed to insert %f into \"%s\"\n" + "Expected \"%s\" or \"%s\", got \"%s\".\n", + value, convertC(formatstr), convertC(checkstr1), + convertC(checkstr2), convertC(buf)); + } +} + +void DoArgumentPrecTest(WCHAR *formatstr, int precision, void *param, + char *paramstr, WCHAR *checkstr1, WCHAR *checkstr2) +{ + WCHAR buf[256]; + + swprintf(buf, formatstr, precision, param); + if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && + memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) + { + Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" + "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, + convertC(formatstr), precision, + convertC(checkstr1), convertC(checkstr2), convertC(buf)); + } +} + +void DoArgumentPrecDoubleTest(WCHAR *formatstr, int precision, double param, + WCHAR *checkstr1, WCHAR *checkstr2) +{ + WCHAR buf[256]; + + swprintf(buf, formatstr, precision, param); + if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && + memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) + { + Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" + "Expected \"%s\" or \"%s\", got \"%s\".\n", param, + convertC(formatstr), precision, + convertC(checkstr1), convertC(checkstr2), convertC(buf)); + } +} + +#endif + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test1/CMakeLists.txt new file mode 100644 index 0000000000..fcf816029e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test1 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test1 coreclrpal) + +target_link_libraries(paltest_swprintf_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.c new file mode 100644 index 0000000000..626040d9f7 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test1/test1.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: test1.c +** +** Purpose: General test to see if swprintf works correctly +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR *checkstr; + WCHAR buf[256]; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + checkstr = convert("hello world"); + swprintf(buf, convert("hello world")); + + if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) + { + Fail("ERROR: Expected \"%s\", got \"%s\".\n", "hello world", + convertC(buf)); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test1/testinfo.dat new file mode 100644 index 0000000000..f43d462daf --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test1 +Description += General test to see if swprintf works correctly diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test10/CMakeLists.txt new file mode 100644 index 0000000000..302c5e5923 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test10 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test10 coreclrpal) + +target_link_libraries(paltest_swprintf_test10 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test10/test10.c b/src/pal/tests/palsuite/c_runtime/swprintf/test10/test10.c new file mode 100644 index 0000000000..61aef593a0 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test10/test10.c @@ -0,0 +1,55 @@ +// 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 swprintf with octal numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoNumTest(convert("foo %o"), pos, convert("foo 52")); + DoNumTest(convert("foo %lo"), 0xFFFF, convert("foo 177777")); + DoNumTest(convert("foo %ho"), 0xFFFF, convert("foo 177777")); + DoNumTest(convert("foo %Lo"), pos, convert("foo 52")); + DoI64Test(convert("foo %I64o"), l, "0x0000000000000042", + convert("foo 52")); + DoNumTest(convert("foo %3o"), pos, convert("foo 52")); + DoNumTest(convert("foo %-3o"), pos, convert("foo 52 ")); + DoNumTest(convert("foo %.1o"), pos, convert("foo 52")); + DoNumTest(convert("foo %.3o"), pos, convert("foo 052")); + DoNumTest(convert("foo %03o"), pos, convert("foo 052")); + DoNumTest(convert("foo %#o"), pos, convert("foo 052")); + DoNumTest(convert("foo %+o"), pos, convert("foo 52")); + DoNumTest(convert("foo % o"), pos, convert("foo 52")); + DoNumTest(convert("foo %+o"), neg, convert("foo 37777777726")); + DoNumTest(convert("foo % o"), neg, convert("foo 37777777726")); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test10/testinfo.dat new file mode 100644 index 0000000000..e860bb26e7 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test10 +Description += Tests swprintf with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test11/CMakeLists.txt new file mode 100644 index 0000000000..484d57ef58 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test11 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test11 coreclrpal) + +target_link_libraries(paltest_swprintf_test11 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test11/test11.c b/src/pal/tests/palsuite/c_runtime/swprintf/test11/test11.c new file mode 100644 index 0000000000..216f9acdbb --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test11/test11.c @@ -0,0 +1,55 @@ +// 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 swprintf with unsigned numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoNumTest(convert("foo %u"), pos, convert("foo 42")); + DoNumTest(convert("foo %lu"), 0xFFFF, convert("foo 65535")); + DoNumTest(convert("foo %hu"), 0xFFFF, convert("foo 65535")); + DoNumTest(convert("foo %Lu"), pos, convert("foo 42")); + DoI64Test(convert("foo %I64u"), l, "0x0000000000000042", + convert("foo 42")); + DoNumTest(convert("foo %3u"), pos, convert("foo 42")); + DoNumTest(convert("foo %-3u"), pos, convert("foo 42 ")); + DoNumTest(convert("foo %.1u"), pos, convert("foo 42")); + DoNumTest(convert("foo %.3u"), pos, convert("foo 042")); + DoNumTest(convert("foo %03u"), pos, convert("foo 042")); + DoNumTest(convert("foo %#u"), pos, convert("foo 42")); + DoNumTest(convert("foo %+u"), pos, convert("foo 42")); + DoNumTest(convert("foo % u"), pos, convert("foo 42")); + DoNumTest(convert("foo %+u"), neg, convert("foo 4294967254")); + DoNumTest(convert("foo % u"), neg, convert("foo 4294967254")); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test11/testinfo.dat new file mode 100644 index 0000000000..430a777e7a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test11 +Description += Tests swprintf with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test12/CMakeLists.txt new file mode 100644 index 0000000000..6d45ee4646 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test12 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test12 coreclrpal) + +target_link_libraries(paltest_swprintf_test12 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test12/test12.c b/src/pal/tests/palsuite/c_runtime/swprintf/test12/test12.c new file mode 100644 index 0000000000..a41b0ddbd3 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test12/test12.c @@ -0,0 +1,56 @@ +// 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 swprintf with hex numbers (lowercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 0x1234ab; + INT64 l = I64(0x1234567887654321); + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoNumTest(convert("foo %x"), pos, convert("foo 1234ab")); + DoNumTest(convert("foo %lx"), pos, convert("foo 1234ab")); + DoNumTest(convert("foo %hx"), pos, convert("foo 34ab")); + DoNumTest(convert("foo %Lx"), pos, convert("foo 1234ab")); + DoI64Test(convert("foo %I64x"), l, "0x1234567887654321", + convert("foo 1234567887654321")); + DoNumTest(convert("foo %7x"), pos, convert("foo 1234ab")); + DoNumTest(convert("foo %-7x"), pos, convert("foo 1234ab ")); + DoNumTest(convert("foo %.1x"), pos, convert("foo 1234ab")); + DoNumTest(convert("foo %.7x"), pos, convert("foo 01234ab")); + DoNumTest(convert("foo %07x"), pos, convert("foo 01234ab")); + DoNumTest(convert("foo %#x"), pos, convert("foo 0x1234ab")); + DoNumTest(convert("foo %+x"), pos, convert("foo 1234ab")); + DoNumTest(convert("foo % x"), pos, convert("foo 1234ab")); + DoNumTest(convert("foo %+x"), neg, convert("foo ffffffd6")); + DoNumTest(convert("foo % x"), neg, convert("foo ffffffd6")); + + PAL_Terminate(); + return PASS; +} + + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test12/testinfo.dat new file mode 100644 index 0000000000..d53582644f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test12 +Description += Tests swprintf with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test13/CMakeLists.txt new file mode 100644 index 0000000000..20f6f0df7b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test13 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test13 coreclrpal) + +target_link_libraries(paltest_swprintf_test13 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test13/test13.c b/src/pal/tests/palsuite/c_runtime/swprintf/test13/test13.c new file mode 100644 index 0000000000..b99232f7ea --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test13/test13.c @@ -0,0 +1,55 @@ +// 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 swprintf with hex numbers (uppercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 0x1234ab; + INT64 l = I64(0x1234567887654321); + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoNumTest(convert("foo %X"), pos, convert("foo 1234AB")); + DoNumTest(convert("foo %lX"), pos, convert("foo 1234AB")); + DoNumTest(convert("foo %hX"), pos, convert("foo 34AB")); + DoNumTest(convert("foo %LX"), pos, convert("foo 1234AB")); + DoI64Test(convert("foo %I64X"), l, "0X1234567887654321", + convert("foo 1234567887654321")); + DoNumTest(convert("foo %7X"), pos, convert("foo 1234AB")); + DoNumTest(convert("foo %-7X"), pos, convert("foo 1234AB ")); + DoNumTest(convert("foo %.1X"), pos, convert("foo 1234AB")); + DoNumTest(convert("foo %.7X"), pos, convert("foo 01234AB")); + DoNumTest(convert("foo %07X"), pos, convert("foo 01234AB")); + DoNumTest(convert("foo %#X"), pos, convert("foo 0X1234AB")); + DoNumTest(convert("foo %+X"), pos, convert("foo 1234AB")); + DoNumTest(convert("foo % X"), pos, convert("foo 1234AB")); + DoNumTest(convert("foo %+X"), neg, convert("foo FFFFFFD6")); + DoNumTest(convert("foo % X"), neg, convert("foo FFFFFFD6")); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test13/testinfo.dat new file mode 100644 index 0000000000..1ce172414c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test13 +Description += Tests swprintf with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test14/CMakeLists.txt new file mode 100644 index 0000000000..a052f60116 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test14 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test14 coreclrpal) + +target_link_libraries(paltest_swprintf_test14 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test14/test14.c b/src/pal/tests/palsuite/c_runtime/swprintf/test14/test14.c new file mode 100644 index 0000000000..bcfd6a7c24 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test14/test14.c @@ -0,0 +1,67 @@ +// 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 swprintf with exponential format doubles (lowercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 256.0; + double neg = -256.0; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoDoubleTest(convert("foo %e"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %le"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %he"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %Le"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %I64e"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %14e"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %-14e"), val, convert("foo 2.560000e+002 "), + convert("foo 2.560000e+02 ")); + DoDoubleTest(convert("foo %.1e"), val, convert("foo 2.6e+002"), + convert("foo 2.6e+02")); + DoDoubleTest(convert("foo %.8e"), val, convert("foo 2.56000000e+002"), + convert("foo 2.56000000e+02")); + DoDoubleTest(convert("foo %014e"), val, convert("foo 02.560000e+002"), + convert("foo 002.560000e+02")); + DoDoubleTest(convert("foo %#e"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %+e"), val, convert("foo +2.560000e+002"), + convert("foo +2.560000e+02")); + DoDoubleTest(convert("foo % e"), val, convert("foo 2.560000e+002"), + convert("foo 2.560000e+02")); + DoDoubleTest(convert("foo %+e"), neg, convert("foo -2.560000e+002"), + convert("foo -2.560000e+02")); + DoDoubleTest(convert("foo % e"), neg, convert("foo -2.560000e+002"), + convert("foo -2.560000e+02")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test14/testinfo.dat new file mode 100644 index 0000000000..7f3451820b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test14 +Description += Tests swprintf with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test15/CMakeLists.txt new file mode 100644 index 0000000000..7bc2da122f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test15 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test15 coreclrpal) + +target_link_libraries(paltest_swprintf_test15 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test15/test15.c b/src/pal/tests/palsuite/c_runtime/swprintf/test15/test15.c new file mode 100644 index 0000000000..215afbe093 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test15/test15.c @@ -0,0 +1,67 @@ +// 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 swprintf with exponential format doubles (uppercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 256.0; + double neg = -256.0; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoDoubleTest(convert("foo %E"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %lE"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %hE"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %LE"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %I64E"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %14E"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %-14E"), val, convert("foo 2.560000E+002 "), + convert("foo 2.560000E+02 ")); + DoDoubleTest(convert("foo %.1E"), val, convert("foo 2.6E+002"), + convert("foo 2.6E+02")); + DoDoubleTest(convert("foo %.8E"), val, convert("foo 2.56000000E+002"), + convert("foo 2.56000000E+02")); + DoDoubleTest(convert("foo %014E"), val, convert("foo 02.560000E+002"), + convert("foo 002.560000E+02")); + DoDoubleTest(convert("foo %#E"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %+E"), val, convert("foo +2.560000E+002"), + convert("foo +2.560000E+02")); + DoDoubleTest(convert("foo % E"), val, convert("foo 2.560000E+002"), + convert("foo 2.560000E+02")); + DoDoubleTest(convert("foo %+E"), neg, convert("foo -2.560000E+002"), + convert("foo -2.560000E+02")); + DoDoubleTest(convert("foo % E"), neg, convert("foo -2.560000E+002"), + convert("foo -2.560000E+02")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test15/testinfo.dat new file mode 100644 index 0000000000..a6044e7bcc --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test15 +Description += Tests swprintf with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test16/CMakeLists.txt new file mode 100644 index 0000000000..e6ad3abd3f --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test16 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test16 coreclrpal) + +target_link_libraries(paltest_swprintf_test16 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test16/test16.c b/src/pal/tests/palsuite/c_runtime/swprintf/test16/test16.c new file mode 100644 index 0000000000..859afed8dd --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test16/test16.c @@ -0,0 +1,67 @@ +// 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 swprintf with decimal point format doubles +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 2560.001; + double neg = -2560.001; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoDoubleTest(convert("foo %f"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %lf"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %hf"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %Lf"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %I64f"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %12f"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %-12f"), val, convert("foo 2560.001000 "), + convert("foo 2560.001000 ")); + DoDoubleTest(convert("foo %.1f"), val, convert("foo 2560.0"), + convert("foo 2560.0")); + DoDoubleTest(convert("foo %.8f"), val, convert("foo 2560.00100000"), + convert("foo 2560.00100000")); + DoDoubleTest(convert("foo %012f"), val, convert("foo 02560.001000"), + convert("foo 02560.001000")); + DoDoubleTest(convert("foo %#f"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %+f"), val, convert("foo +2560.001000"), + convert("foo +2560.001000")); + DoDoubleTest(convert("foo % f"), val, convert("foo 2560.001000"), + convert("foo 2560.001000")); + DoDoubleTest(convert("foo %+f"), neg, convert("foo -2560.001000"), + convert("foo -2560.001000")); + DoDoubleTest(convert("foo % f"), neg, convert("foo -2560.001000"), + convert("foo -2560.001000")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test16/testinfo.dat new file mode 100644 index 0000000000..d2f9a125c4 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test16 +Description += Tests swprintf with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test17/CMakeLists.txt new file mode 100644 index 0000000000..401285b740 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test17 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test17 coreclrpal) + +target_link_libraries(paltest_swprintf_test17 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test17/test17.c b/src/pal/tests/palsuite/c_runtime/swprintf/test17/test17.c new file mode 100644 index 0000000000..480f2b2fe1 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test17/test17.c @@ -0,0 +1,69 @@ +// 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 swprintf with compact format doubles (lowercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 2560.001; + double neg = -2560.001; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoDoubleTest(convert("foo %g"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %lg"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %hg"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %Lg"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %I64g"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %5g"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %-5g"), val, convert("foo 2560 "), + convert("foo 2560 ")); + DoDoubleTest(convert("foo %.1g"), val, convert("foo 3e+003"), + convert("foo 3e+03")); + DoDoubleTest(convert("foo %.2g"), val, convert("foo 2.6e+003"), + convert("foo 2.6e+03")); + DoDoubleTest(convert("foo %.12g"), val, convert("foo 2560.001"), + convert("foo 2560.001")); + DoDoubleTest(convert("foo %06g"), val, convert("foo 002560"), + convert("foo 002560")); + DoDoubleTest(convert("foo %#g"), val, convert("foo 2560.00"), + convert("foo 2560.00")); + DoDoubleTest(convert("foo %+g"), val, convert("foo +2560"), + convert("foo +2560")); + DoDoubleTest(convert("foo % g"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %+g"), neg, convert("foo -2560"), + convert("foo -2560")); + DoDoubleTest(convert("foo % g"), neg, convert("foo -2560"), + convert("foo -2560")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test17/testinfo.dat new file mode 100644 index 0000000000..f26029c659 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test17 +Description += Tests swprintf with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test18/CMakeLists.txt new file mode 100644 index 0000000000..210ab2c7ec --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test18/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test18.c +) + +add_executable(paltest_swprintf_test18 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test18 coreclrpal) + +target_link_libraries(paltest_swprintf_test18 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test18/test18.c b/src/pal/tests/palsuite/c_runtime/swprintf/test18/test18.c new file mode 100644 index 0000000000..1ed8cd00d8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test18/test18.c @@ -0,0 +1,69 @@ +// 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: test18.c +** +** Purpose: Tests swprintf with compact format doubles (uppercase) +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + double val = 2560.001; + double neg = -2560.001; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoDoubleTest(convert("foo %G"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %lG"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %hG"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %LG"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %I64G"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %5G"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %-5G"), val, convert("foo 2560 "), + convert("foo 2560 ")); + DoDoubleTest(convert("foo %.1G"), val, convert("foo 3E+003"), + convert("foo 3E+03")); + DoDoubleTest(convert("foo %.2G"), val, convert("foo 2.6E+003"), + convert("foo 2.6E+03")); + DoDoubleTest(convert("foo %.12G"), val, convert("foo 2560.001"), + convert("foo 2560.001")); + DoDoubleTest(convert("foo %06G"), val, convert("foo 002560"), + convert("foo 002560")); + DoDoubleTest(convert("foo %#G"), val, convert("foo 2560.00"), + convert("foo 2560.00")); + DoDoubleTest(convert("foo %+G"), val, convert("foo +2560"), + convert("foo +2560")); + DoDoubleTest(convert("foo % G"), val, convert("foo 2560"), + convert("foo 2560")); + DoDoubleTest(convert("foo %+G"), neg, convert("foo -2560"), + convert("foo -2560")); + DoDoubleTest(convert("foo % G"), neg, convert("foo -2560"), + convert("foo -2560")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test18/testinfo.dat new file mode 100644 index 0000000000..6a8ca702ff --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test18/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test18 +Description += Tests swprintf with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test19/CMakeLists.txt new file mode 100644 index 0000000000..b9d44a3031 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test19/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + test19.c +) + +add_executable(paltest_swprintf_test19 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test19 coreclrpal) + +target_link_libraries(paltest_swprintf_test19 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.c b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.c new file mode 100644 index 0000000000..5199cc3cd9 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.c @@ -0,0 +1,109 @@ +// 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: test19.c +** +** Purpose: Tests swprintf with argument specified precision +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int n = -1; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + DoArgumentPrecTest(convert("%.*s"), 2, convert("bar"), "bar", + convert("ba"), convert("ba")); + DoArgumentPrecTest(convert("%.*S"), 2, "bar", "bar", convert("ba"), + convert("ba")); + DoArgumentPrecTest(convert("%.*n"), 3, &n, "pointer to int", convert(""), + convert("")); + if (n != 0) + { + Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", + 0, n); + } + + DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", convert("a"), + convert("a")); + DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", convert("a"), + convert("a")); + DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', "a", convert("a"), + convert("a")); + DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', "a", convert("a"), + convert("a")); + DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, "42", convert("42"), + convert("42")); + DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, "42", convert("042"), + convert("042")); + DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, "42", convert("42"), + convert("42")); + DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, "42", convert("042"), + convert("042")); + DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, "42", convert("52"), + convert("52")); + DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, "42", convert("052"), + convert("052")); + DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, "42", convert("42"), + convert("42")); + DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, "42", convert("042"), + convert("042")); + DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, "0x42", convert("42"), + convert("42")); + DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, "0x42", convert("042"), + convert("042")); + DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, "0x42", convert("42"), + convert("42")); + DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, "0x42", convert("042"), + convert("042")); + + + DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, convert("2.0e+000"), + convert("2.0e+000")); + DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, convert("2.010e+000"), + convert("2.010e+000")); + DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, convert("2.0E+000"), + convert("2.0E+000")); + DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, convert("2.010E+000"), + convert("2.010E+000")); + DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, convert("2.0"), + convert("2.0")); + DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, convert("2.010"), + convert("2.010")); + DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, convert("3e+002"), + convert("3e+002")); + DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, convert("256"), + convert("256")); + DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, convert("256"), + convert("256")); + DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, convert("256.01"), + convert("256.01")); + DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, convert("3E+002"), + convert("3E+002")); + DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, convert("256"), + convert("256")); + DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, convert("256"), + convert("256")); + DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, convert("256.01"), + convert("256.01")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test19/testinfo.dat new file mode 100644 index 0000000000..cbd572a35c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test19/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test19 +Description += Tests swprintf with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test2/CMakeLists.txt new file mode 100644 index 0000000000..84446d5f6d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test2 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test2 coreclrpal) + +target_link_libraries(paltest_swprintf_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test2/test2.c b/src/pal/tests/palsuite/c_runtime/swprintf/test2/test2.c new file mode 100644 index 0000000000..deffd3edd7 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test2/test2.c @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*============================================================================ +** +** Source: test2.c +** +** Purpose: Tests swprintf with strings +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + + +int __cdecl main(int argc, char *argv[]) +{ + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + DoWStrTest(convert("foo %s"), convert("bar"), convert("foo bar")); + DoStrTest(convert("foo %hs"), "bar", convert("foo bar")); + DoWStrTest(convert("foo %ws"), convert("bar"), convert("foo bar")); + DoWStrTest(convert("foo %ls"), convert("bar"), convert("foo bar")); + DoWStrTest(convert("foo %Ls"), convert("bar"), convert("foo bar")); + DoWStrTest(convert("foo %I64s"), convert("bar"), convert("foo bar")); + DoWStrTest(convert("foo %5s"), convert("bar"), convert("foo bar")); + DoWStrTest(convert("foo %.2s"), convert("bar"), convert("foo ba")); + DoWStrTest(convert("foo %5.2s"), convert("bar"), convert("foo ba")); + DoWStrTest(convert("foo %-5s"), convert("bar"), convert("foo bar ")); + DoWStrTest(convert("foo %05s"), convert("bar"), convert("foo 00bar")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test2/testinfo.dat new file mode 100644 index 0000000000..d93fa7b400 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test2 +Description += Tests swprintf with strings diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test3/CMakeLists.txt new file mode 100644 index 0000000000..6dbd8a3c36 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test3 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test3 coreclrpal) + +target_link_libraries(paltest_swprintf_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test3/test3.c b/src/pal/tests/palsuite/c_runtime/swprintf/test3/test3.c new file mode 100644 index 0000000000..42875c0640 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test3/test3.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: test3.c +** +** Purpose: Tests swprintf with wide strings +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + DoStrTest(convert("foo %S"), "bar", convert("foo bar")); + DoStrTest(convert("foo %hS"), "bar", convert("foo bar")); + DoWStrTest(convert("foo %lS"), convert("bar"), convert("foo bar")); + DoWStrTest(convert("foo %wS"), convert("bar"), convert("foo bar")); + DoStrTest(convert("foo %LS"), "bar", convert("foo bar")); + DoStrTest(convert("foo %I64S"), "bar", convert("foo bar")); + DoStrTest(convert("foo %5S"), "bar", convert("foo bar")); + DoStrTest(convert("foo %.2S"), "bar", convert("foo ba")); + DoStrTest(convert("foo %5.2S"),"bar", convert("foo ba")); + DoStrTest(convert("foo %-5S"), "bar", convert("foo bar ")); + DoStrTest(convert("foo %05S"), "bar", convert("foo 00bar")); + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test3/testinfo.dat new file mode 100644 index 0000000000..923a8f0efd --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test3 +Description += Tests swprintf with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test4/CMakeLists.txt new file mode 100644 index 0000000000..a665948c47 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test4 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test4 coreclrpal) + +target_link_libraries(paltest_swprintf_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test4/test4.c b/src/pal/tests/palsuite/c_runtime/swprintf/test4/test4.c new file mode 100644 index 0000000000..02cc3f9005 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test4/test4.c @@ -0,0 +1,71 @@ +// 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 swprintf with pointers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + + +int __cdecl main(int argc, char *argv[]) +{ + void *ptr = (void*) 0x123456; + INT64 lptr = I64(0x1234567887654321); + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } +/* +** Run only on 64 bit platforms +*/ +#if defined(BIT64) && defined(PLATFORM_UNIX) + Trace("Testing for 64 Bit Platforms \n"); + DoPointerTest(convert("%p"), NULL, convert("0000000000000000")); + DoPointerTest(convert("%p"), ptr, convert("0000000000123456")); + DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456")); + DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456")); + DoPointerTest(convert("%-17p"), ptr, convert("0000000000123456 ")); + DoPointerTest(convert("%+p"), ptr, convert("0000000000123456")); + DoPointerTest(convert("% p"), ptr, convert("0000000000123456")); + DoPointerTest(convert("%#p"), ptr, convert("0X0000000000123456")); + DoPointerTest(convert("%lp"), ptr, convert("00123456")); + DoPointerTest(convert("%hp"), ptr, convert("00003456")); + DoPointerTest(convert("%Lp"), ptr, convert("00123456")); + DoI64Test(convert("%I64p"), lptr, "pointer to 0X1234567887654321", + convert("1234567887654321")); +#else + Trace("Testing for Non 64 Bit Platforms \n"); + DoPointerTest(convert("%p"), NULL, convert("00000000")); + DoPointerTest(convert("%p"), ptr, convert("00123456")); + DoPointerTest(convert("%9p"), ptr, convert(" 00123456")); + DoPointerTest(convert("%09p"), ptr, convert(" 00123456")); + DoPointerTest(convert("%-9p"), ptr, convert("00123456 ")); + DoPointerTest(convert("%+p"), ptr, convert("00123456")); + DoPointerTest(convert("% p"), ptr, convert("00123456")); + DoPointerTest(convert("%#p"), ptr, convert("0X00123456")); + DoPointerTest(convert("%lp"), ptr, convert("00123456")); + DoPointerTest(convert("%hp"), ptr, convert("00003456")); + DoPointerTest(convert("%Lp"), ptr, convert("00123456")); + DoI64Test(convert("%I64p"), lptr, "pointer to 0X1234567887654321", + convert("1234567887654321")); +#endif + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test4/testinfo.dat new file mode 100644 index 0000000000..dc481d32f1 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test4 +Description += Tests swprintf with pointers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test5/CMakeLists.txt new file mode 100644 index 0000000000..8268ec2963 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test5 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test5 coreclrpal) + +target_link_libraries(paltest_swprintf_test5 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.c b/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.c new file mode 100644 index 0000000000..e85adc120e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test5/test5.c @@ -0,0 +1,67 @@ +// 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 swprintf with the count specifier +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR *longStr; + WCHAR *longResult; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + longStr = + convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." + "..................useless-filler.................................." + "..................useless-filler.................................." + "..................useless-filler.................................." + "%n bar"); + longResult = + convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." + "..................useless-filler.................................." + "..................useless-filler.................................." + "..................useless-filler.................................." + " bar"); + + DoCountTest(convert("foo %n bar"), 4, convert("foo bar")); + DoCountTest(longStr, 257, longResult); + DoCountTest(convert("fo%n bar"), 2, convert("fo bar")); + DoCountTest(convert("%n"), 0, convert("")); + DoCountTest(convert("foo %#n bar"), 4, convert("foo bar")); + DoCountTest(convert("foo % n bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %+n bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %-n bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %0n bar"), 4, convert("foo bar")); + DoShortCountTest(convert("foo %hn bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %ln bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %Ln bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %I64n bar"), 4, convert("foo bar")); + DoCountTest(convert("foo %20.3n bar"), 4, convert("foo bar")); + + PAL_Terminate(); + + free(longStr); + free(longResult); + + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test5/testinfo.dat new file mode 100644 index 0000000000..ef1f1ffc5a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test5 +Description += Tests swprintf with the count specifier diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test6/CMakeLists.txt new file mode 100644 index 0000000000..6a90c0b88e --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test6 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test6 coreclrpal) + +target_link_libraries(paltest_swprintf_test6 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test6/test6.c b/src/pal/tests/palsuite/c_runtime/swprintf/test6/test6.c new file mode 100644 index 0000000000..ecd6374264 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test6/test6.c @@ -0,0 +1,47 @@ +// 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 swprintf with character +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR wb = (WCHAR) 'b'; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoWCharTest(convert("foo %c"), wb, convert("foo b")); + DoCharTest(convert("foo %hc"), 'c', convert("foo c")); + DoWCharTest(convert("foo %lc"), wb, convert("foo b")); + DoWCharTest(convert("foo %Lc"), wb, convert("foo b")); + DoWCharTest(convert("foo %I64c"), wb, convert("foo b")); + DoWCharTest(convert("foo %5c"), wb, convert("foo b")); + DoWCharTest(convert("foo %.0c"), wb, convert("foo b")); + DoWCharTest(convert("foo %-5c"), wb, convert("foo b ")); + DoWCharTest(convert("foo %05c"), wb, convert("foo 0000b")); + DoWCharTest(convert("foo % c"), wb, convert("foo b")); + DoWCharTest(convert("foo %#c"), wb, convert("foo b")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test6/testinfo.dat new file mode 100644 index 0000000000..4224d19519 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test6 +Description += Tests swprintf with characters diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test7/CMakeLists.txt new file mode 100644 index 0000000000..2b1c30cb56 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test7 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test7 coreclrpal) + +target_link_libraries(paltest_swprintf_test7 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test7/test7.c b/src/pal/tests/palsuite/c_runtime/swprintf/test7/test7.c new file mode 100644 index 0000000000..e231ada3d2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test7/test7.c @@ -0,0 +1,48 @@ +// 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 swprintf with wide characters +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + + +int __cdecl main(int argc, char *argv[]) +{ + WCHAR wb = (WCHAR) 'b'; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoCharTest(convert("foo %C"), 'c', convert("foo c")); + DoWCharTest(convert("foo %hc"), wb, convert("foo b")); + DoCharTest(convert("foo %lC"), 'c', convert("foo c")); + DoCharTest(convert("foo %LC"), 'c', convert("foo c")); + DoCharTest(convert("foo %I64C"), 'c', convert("foo c")); + DoCharTest(convert("foo %5C"), 'c', convert("foo c")); + DoCharTest(convert("foo %.0C"), 'c', convert("foo c")); + DoCharTest(convert("foo %-5C"), 'c', convert("foo c ")); + DoCharTest(convert("foo %05C"), 'c', convert("foo 0000c")); + DoCharTest(convert("foo % C"), 'c', convert("foo c")); + DoCharTest(convert("foo %#C"), 'c', convert("foo c")); + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test7/testinfo.dat new file mode 100644 index 0000000000..7facc90b58 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test7 +Description += Tests swprintf with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test8/CMakeLists.txt new file mode 100644 index 0000000000..281e6df097 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test8 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test8 coreclrpal) + +target_link_libraries(paltest_swprintf_test8 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test8/test8.c b/src/pal/tests/palsuite/c_runtime/swprintf/test8/test8.c new file mode 100644 index 0000000000..b4be28e78d --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test8/test8.c @@ -0,0 +1,55 @@ +// 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 swprintf with decimal numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoNumTest(convert("foo %d"), pos, convert("foo 42")); + DoNumTest(convert("foo %ld"), 0xFFFF, convert("foo 65535")); + DoNumTest(convert("foo %hd"), 0xFFFF, convert("foo -1")); + DoNumTest(convert("foo %Ld"), pos, convert("foo 42")); + DoI64Test(convert("foo %I64d"), l, "0x0000000000000042", + convert("foo 42")); + DoNumTest(convert("foo %3d"), pos, convert("foo 42")); + DoNumTest(convert("foo %-3d"), pos, convert("foo 42 ")); + DoNumTest(convert("foo %.1d"), pos, convert("foo 42")); + DoNumTest(convert("foo %.3d"), pos, convert("foo 042")); + DoNumTest(convert("foo %03d"), pos, convert("foo 042")); + DoNumTest(convert("foo %#d"), pos, convert("foo 42")); + DoNumTest(convert("foo %+d"), pos, convert("foo +42")); + DoNumTest(convert("foo % d"), pos, convert("foo 42")); + DoNumTest(convert("foo %+d"), neg, convert("foo -42")); + DoNumTest(convert("foo % d"), neg, convert("foo -42")); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test8/testinfo.dat new file mode 100644 index 0000000000..d5858b2cfe --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test8 +Description += Tests swprintf with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test9/CMakeLists.txt new file mode 100644 index 0000000000..054b40a998 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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_swprintf_test9 + ${SOURCES} +) + +add_dependencies(paltest_swprintf_test9 coreclrpal) + +target_link_libraries(paltest_swprintf_test9 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test9/test9.c b/src/pal/tests/palsuite/c_runtime/swprintf/test9/test9.c new file mode 100644 index 0000000000..2f5429e5fd --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/test9/test9.c @@ -0,0 +1,55 @@ +// 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 swprintf with integer numbers +** +** +**==========================================================================*/ + + + +#include <palsuite.h> +#include "../swprintf.h" + +/* + * Uses memcmp & wcslen + */ + +int __cdecl main(int argc, char *argv[]) +{ + int neg = -42; + int pos = 42; + INT64 l = 42; + + if (PAL_Initialize(argc, argv) != 0) + { + return FAIL; + } + + + DoNumTest(convert("foo %i"), pos, convert("foo 42")); + DoNumTest(convert("foo %li"), 0xFFFF, convert("foo 65535")); + DoNumTest(convert("foo %hi"), 0xFFFF, convert("foo -1")); + DoNumTest(convert("foo %Li"), pos, convert("foo 42")); + DoI64Test(convert("foo %I64i"), l, "0x0000000000000042", + convert("foo 42")); + DoNumTest(convert("foo %3i"), pos, convert("foo 42")); + DoNumTest(convert("foo %-3i"), pos, convert("foo 42 ")); + DoNumTest(convert("foo %.1i"), pos, convert("foo 42")); + DoNumTest(convert("foo %.3i"), pos, convert("foo 042")); + DoNumTest(convert("foo %03i"), pos, convert("foo 042")); + DoNumTest(convert("foo %#i"), pos, convert("foo 42")); + DoNumTest(convert("foo %+i"), pos, convert("foo +42")); + DoNumTest(convert("foo % i"), pos, convert("foo 42")); + DoNumTest(convert("foo %+i"), neg, convert("foo -42")); + DoNumTest(convert("foo % i"), neg, convert("foo -42")); + + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test9/testinfo.dat new file mode 100644 index 0000000000..7ef9eed134 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/swprintf/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 = swprintf +Name = Positive Test for swprintf +TYPE = DEFAULT +EXE1 = test9 +Description += Tests swprintf with integer numbers |