summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/vfprintf
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/vfprintf')
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/CMakeLists.txt22
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test1/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.c69
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.c53
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.c52
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.c54
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.c55
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.c55
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.c55
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.c51
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.c53
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.c52
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.c77
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.c46
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.c46
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.c71
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.c61
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.c49
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.c48
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.c54
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt20
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.c54
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat12
-rw-r--r--src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h464
59 files changed, 2149 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/CMakeLists.txt
new file mode 100644
index 0000000000..cafb9536b0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/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/vfprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/CMakeLists.txt
new file mode 100644
index 0000000000..c68965e7de
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_vfprintf_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test1 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test1
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.c
new file mode 100644
index 0000000000..7a03387083
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.c
@@ -0,0 +1,69 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test1.c
+**
+** Purpose: Test #1 for the vfprintf function. A single, basic, test
+** case with no formatting.
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ FILE *fp;
+ char testfile[] = "testfile.txt";
+ char buf[256];
+ char checkstr[] = "hello world";
+ int ret;
+
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ if ((fp = fopen(testfile, "w+")) == NULL)
+ {
+ Fail("ERROR: fopen failed to create \"%s\"\n", testfile);
+ }
+
+ ret = DoVfprintf(fp, "hello world");
+
+ if (ret != strlen(checkstr))
+ {
+ Fail("Expected vfprintf to return %d, got %d.\n",
+ strlen(checkstr), ret);
+
+ }
+
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: Fseek failed to set pointer to beginning of file\n" );
+ }
+
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+ if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0)
+ {
+ Fail("ERROR: expected %s, got %s\n", checkstr, buf);
+ }
+ if ((fclose(fp)) != 0)
+ {
+ Fail("ERROR: fclose failed to close \"%s\"\n", testfile);
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat
new file mode 100644
index 0000000000..1704394fc8
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= General test to see if vfprintf works correctly
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt
new file mode 100644
index 0000000000..e124beae34
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test10.c
+)
+
+add_executable(paltest_vfprintf_test10
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test10 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test10
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.c
new file mode 100644
index 0000000000..0a3e2ef29e
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.c
@@ -0,0 +1,53 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test10.c
+**
+** Purpose: Test #10 for the vfprintf function. Tests the octal specifier
+** (%o).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int neg = -42;
+ int pos = 42;
+ INT64 l = 42;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoNumTest("foo %o", pos, "foo 52");
+ DoNumTest("foo %lo", 0xFFFF, "foo 177777");
+ DoNumTest("foo %ho", 0xFFFF, "foo 177777");
+ DoNumTest("foo %Lo", pos, "foo 52");
+ DoI64Test("foo %I64o", l, "42", "foo 52");
+ DoNumTest("foo %3o", pos, "foo 52");
+ DoNumTest("foo %-3o", pos, "foo 52 ");
+ DoNumTest("foo %.1o", pos, "foo 52");
+ DoNumTest("foo %.3o", pos, "foo 052");
+ DoNumTest("foo %03o", pos, "foo 052");
+ DoNumTest("foo %#o", pos, "foo 052");
+ DoNumTest("foo %+o", pos, "foo 52");
+ DoNumTest("foo % o", pos, "foo 52");
+ DoNumTest("foo %+o", neg, "foo 37777777726");
+ DoNumTest("foo % o", neg, "foo 37777777726");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat
new file mode 100644
index 0000000000..815bc010e4
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test10
+Description
+= Tests vfprintf with octal numbers
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt
new file mode 100644
index 0000000000..64e7e290bc
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test11.c
+)
+
+add_executable(paltest_vfprintf_test11
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test11 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test11
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.c
new file mode 100644
index 0000000000..69aae0c14a
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.c
@@ -0,0 +1,52 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test11.c
+**
+** Purpose: Test #11 for the vfprintf function. Test the unsigned int
+** specifier (%u).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+int __cdecl main(int argc, char *argv[])
+{
+ int neg = -42;
+ int pos = 42;
+ INT64 l = 42;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoNumTest("foo %u", pos, "foo 42");
+ DoNumTest("foo %lu", 0xFFFF, "foo 65535");
+ DoNumTest("foo %hu", 0xFFFF, "foo 65535");
+ DoNumTest("foo %Lu", pos, "foo 42");
+ DoI64Test("foo %I64u", l, "42", "foo 42");
+ DoNumTest("foo %3u", pos, "foo 42");
+ DoNumTest("foo %-3u", pos, "foo 42 ");
+ DoNumTest("foo %.1u", pos, "foo 42");
+ DoNumTest("foo %.3u", pos, "foo 042");
+ DoNumTest("foo %03u", pos, "foo 042");
+ DoNumTest("foo %#u", pos, "foo 42");
+ DoNumTest("foo %+u", pos, "foo 42");
+ DoNumTest("foo % u", pos, "foo 42");
+ DoNumTest("foo %+u", neg, "foo 4294967254");
+ DoNumTest("foo % u", neg, "foo 4294967254");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat
new file mode 100644
index 0000000000..57bb989389
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test11
+Description
+= Tests vfprintf with unsigned numbers
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt
new file mode 100644
index 0000000000..8f1a550c2f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test12.c
+)
+
+add_executable(paltest_vfprintf_test12
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test12 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test12
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.c
new file mode 100644
index 0000000000..4efb53129a
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.c
@@ -0,0 +1,54 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test12.c
+**
+** Purpose: Test #12 for the vfprintf function. Tests the (lowercase)
+** hexadecimal specifier (%x)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int neg = -42;
+ int pos = 0x1234ab;
+ INT64 l = I64(0x1234567887654321);
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoNumTest("foo %x", pos, "foo 1234ab");
+ DoNumTest("foo %lx", pos, "foo 1234ab");
+ DoNumTest("foo %hx", pos, "foo 34ab");
+ DoNumTest("foo %Lx", pos, "foo 1234ab");
+ DoI64Test("foo %I64x", l, "0x1234567887654321",
+ "foo 1234567887654321");
+ DoNumTest("foo %7x", pos, "foo 1234ab");
+ DoNumTest("foo %-7x", pos, "foo 1234ab ");
+ DoNumTest("foo %.1x", pos, "foo 1234ab");
+ DoNumTest("foo %.7x", pos, "foo 01234ab");
+ DoNumTest("foo %07x", pos, "foo 01234ab");
+ DoNumTest("foo %#x", pos, "foo 0x1234ab");
+ DoNumTest("foo %+x", pos, "foo 1234ab");
+ DoNumTest("foo % x", pos, "foo 1234ab");
+ DoNumTest("foo %+x", neg, "foo ffffffd6");
+ DoNumTest("foo % x", neg, "foo ffffffd6");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat
new file mode 100644
index 0000000000..d406547e3d
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test12
+Description
+= Tests vfprintf with hex numbers (lowercase)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt
new file mode 100644
index 0000000000..b0e334bbc0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test13.c
+)
+
+add_executable(paltest_vfprintf_test13
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test13 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test13
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.c
new file mode 100644
index 0000000000..97887515f2
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.c
@@ -0,0 +1,55 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test13.c
+**
+** Purpose: Test #13 for the vfprintf function. Tests the (uppercase)
+** hexadecimal specifier (%X)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int neg = -42;
+ int pos = 0x1234AB;
+ INT64 l = I64(0x1234567887654321);
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoNumTest("foo %X", pos, "foo 1234AB");
+ DoNumTest("foo %lX", pos, "foo 1234AB");
+ DoNumTest("foo %hX", pos, "foo 34AB");
+ DoNumTest("foo %LX", pos, "foo 1234AB");
+ DoI64Test("foo %I64X", l, "0x1234567887654321",
+ "foo 1234567887654321");
+ DoNumTest("foo %7X", pos, "foo 1234AB");
+ DoNumTest("foo %-7X", pos, "foo 1234AB ");
+ DoNumTest("foo %.1X", pos, "foo 1234AB");
+ DoNumTest("foo %.7X", pos, "foo 01234AB");
+ DoNumTest("foo %07X", pos, "foo 01234AB");
+ DoNumTest("foo %#X", pos, "foo 0X1234AB");
+ DoNumTest("foo %+X", pos, "foo 1234AB");
+ DoNumTest("foo % X", pos, "foo 1234AB");
+ DoNumTest("foo %+X", neg, "foo FFFFFFD6");
+ DoNumTest("foo % X", neg, "foo FFFFFFD6");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat
new file mode 100644
index 0000000000..d77e478bd7
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test13
+Description
+= Tests vfprintf with hex numbers (uppercase)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt
new file mode 100644
index 0000000000..72282ed8f4
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test14.c
+)
+
+add_executable(paltest_vfprintf_test14
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test14 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test14
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.c
new file mode 100644
index 0000000000..59e55f1c92
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.c
@@ -0,0 +1,55 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test14.c
+**
+** Purpose: Test #14 for the vfprintf function. Tests the lowercase
+** exponential notation double specifier (%e)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ double val = 256.0;
+ double neg = -256.0;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ",
+ "foo 2.560000e+02 ");
+ DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02");
+ DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002",
+ "foo 2.56000000e+02");
+ DoDoubleTest("foo %014e", val, "foo 02.560000e+002",
+ "foo 002.560000e+02");
+ DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02");
+ DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02");
+ DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02");
+ DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat
new file mode 100644
index 0000000000..468f21cb57
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test14
+Description
+= Tests vfprintf with exponential format doubles (lowercase)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt
new file mode 100644
index 0000000000..2c1a148b5b
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test15.c
+)
+
+add_executable(paltest_vfprintf_test15
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test15 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test15
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.c
new file mode 100644
index 0000000000..186db1f426
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.c
@@ -0,0 +1,55 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test15.c
+**
+** Purpose: Test #15 for the vfprintf function. Tests the uppercase
+** exponential notation double specifier (%E)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ double val = 256.0;
+ double neg = -256.0;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ",
+ "foo 2.560000E+02 ");
+ DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02");
+ DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002",
+ "foo 2.56000000E+02");
+ DoDoubleTest("foo %014E", val, "foo 02.560000E+002",
+ "foo 002.560000E+02");
+ DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02");
+ DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02");
+ DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02");
+ DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat
new file mode 100644
index 0000000000..01e72e7232
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test15
+Description
+= Tests vfprintf with exponential format doubles (uppercase)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt
new file mode 100644
index 0000000000..e62a57dc60
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test16.c
+)
+
+add_executable(paltest_vfprintf_test16
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test16 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test16
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.c
new file mode 100644
index 0000000000..e0ccce6c35
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.c
@@ -0,0 +1,51 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test16.c
+**
+** Purpose: Test #16 for the vfprintf function. Tests the decimal notation
+** double specifier (%f)
+**
+**
+**==========================================================================*/
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ double val = 2560.001;
+ double neg = -2560.001;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 ");
+ DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0");
+ DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000");
+ DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000");
+ DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000");
+ DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000");
+ DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000");
+ DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat
new file mode 100644
index 0000000000..e8dc15cab4
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test16
+Description
+= Tests vfprintf with decimal point format doubles
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt
new file mode 100644
index 0000000000..5ea2a0a56d
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test17.c
+)
+
+add_executable(paltest_vfprintf_test17
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test17 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test17
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.c
new file mode 100644
index 0000000000..dc700c7ab0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.c
@@ -0,0 +1,53 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test17.c
+**
+** Purpose: Test #17 for the vfprintf function. Tests the lowercase
+** shorthand notation double specifier (%g)
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ double val = 2560.001;
+ double neg = -2560.001;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoDoubleTest("foo %g", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 ");
+ DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03");
+ DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03");
+ DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001");
+ DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560");
+ DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00");
+ DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560");
+ DoDoubleTest("foo % g", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560");
+ DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat
new file mode 100644
index 0000000000..0ce1a850f4
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test17
+Description
+= Tests vfprintf with compact format doubles (lowercase)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt
new file mode 100644
index 0000000000..c30168b1b5
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test18.c
+)
+
+add_executable(paltest_vfprintf_test18
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test18 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test18
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.c
new file mode 100644
index 0000000000..0f3fa519c5
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.c
@@ -0,0 +1,52 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test18.c
+**
+** Purpose: Test #18 for the vfprintf function. Tests the uppercase
+** shorthand notation double specifier (%G)
+**
+**
+**==========================================================================*/
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ double val = 2560.001;
+ double neg = -2560.001;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoDoubleTest("foo %G", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 ");
+ DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03");
+ DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03");
+ DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001");
+ DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560");
+ DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00");
+ DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560");
+ DoDoubleTest("foo % G", val, "foo 2560", "foo 2560");
+ DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560");
+ DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat
new file mode 100644
index 0000000000..1f91c7a707
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test18
+Description
+= Tests vfprintf with compact format doubles (uppercase)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt
new file mode 100644
index 0000000000..7bedd99335
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test19.c
+)
+
+add_executable(paltest_vfprintf_test19
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test19 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test19
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.c
new file mode 100644
index 0000000000..3d8b09a81d
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.c
@@ -0,0 +1,77 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test19.c
+**
+** Purpose: Test #19 for the vfprintf function. Tests the variable length
+** precision argument.
+**
+**
+**==========================================================================*/
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int n = -1;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoArgumentPrecTest("%.*s", 2, "bar", "bar", "ba", "ba");
+ DoArgumentPrecTest("%.*S", 2, convert("bar"), "bar", "ba", "ba");
+
+ DoArgumentPrecTest("%.*n ", 3, &n, "pointer to int", " ", " ");
+ if (n != 0)
+ {
+ Fail("ERROR: Expected count parameter to resolve to %d, got %X\n",
+ 0, n);
+ }
+
+ DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a");
+ DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a");
+ DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a");
+ DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a");
+ DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42");
+ DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042");
+ DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42");
+ DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042");
+ DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52");
+ DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052");
+ DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42");
+ DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042");
+ DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42");
+ DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042");
+ DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42");
+ DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042");
+
+
+ DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00");
+ DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00");
+ DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00");
+ DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00");
+ DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0");
+ DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010");
+ DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02");
+ DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256");
+ DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256");
+ DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01");
+ DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02");
+ DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256");
+ DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256");
+ DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01");
+
+ PAL_Terminate();
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat
new file mode 100644
index 0000000000..7e2ac8beae
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test19
+Description
+= Tests vfprintf with argument specified precision
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt
new file mode 100644
index 0000000000..7fd7e07f72
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test2.c
+)
+
+add_executable(paltest_vfprintf_test2
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test2 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test2
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.c
new file mode 100644
index 0000000000..991951c13f
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.c
@@ -0,0 +1,46 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test2.c
+**
+** Purpose: Test #2 for the vfprintf function. Tests the string specifier
+** (%s).
+**
+**
+**==========================================================================*/
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoStrTest("foo %s", "bar", "foo bar");
+ DoStrTest("foo %hs", "bar", "foo bar");
+ DoWStrTest("foo %ls", convert("bar"), "foo bar");
+ DoWStrTest("foo %ws", convert("bar"), "foo bar");
+ DoStrTest("foo %Ls", "bar", "foo bar");
+ DoStrTest("foo %I64s", "bar", "foo bar");
+ DoStrTest("foo %5s", "bar", "foo bar");
+ DoStrTest("foo %.2s", "bar", "foo ba");
+ DoStrTest("foo %5.2s", "bar", "foo ba");
+ DoStrTest("foo %-5s", "bar", "foo bar ");
+ DoStrTest("foo %05s", "bar", "foo 00bar");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat
new file mode 100644
index 0000000000..f86a84c4d7
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test2
+Description
+= Tests vfprintf with strings
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt
new file mode 100644
index 0000000000..7e421b64ad
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test3.c
+)
+
+add_executable(paltest_vfprintf_test3
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test3 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test3
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.c
new file mode 100644
index 0000000000..95726ebd35
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.c
@@ -0,0 +1,46 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test3.c
+**
+** Purpose: Test #3 for the vfprintf function. Tests the wide string
+** specifier (%S).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoWStrTest("foo %S", convert("bar"), "foo bar");
+ DoStrTest("foo %hS", "bar", "foo bar");
+ DoWStrTest("foo %lS", convert("bar"), "foo bar");
+ DoWStrTest("foo %wS", convert("bar"), "foo bar");
+ DoWStrTest("foo %LS", convert("bar"), "foo bar");
+ DoWStrTest("foo %I64S", convert("bar"), "foo bar");
+ DoWStrTest("foo %5S", convert("bar"), "foo bar");
+ DoWStrTest("foo %.2S", convert("bar"), "foo ba");
+ DoWStrTest("foo %5.2S", convert("bar"), "foo ba");
+ DoWStrTest("foo %-5S", convert("bar"), "foo bar ");
+ DoWStrTest("foo %05S", convert("bar"), "foo 00bar");
+
+ PAL_Terminate();
+ return PASS;
+}
+
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat
new file mode 100644
index 0000000000..9c104fd5ca
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test3
+Description
+= Tests vfprintf with wide strings
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt
new file mode 100644
index 0000000000..b7902433cc
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test4.c
+)
+
+add_executable(paltest_vfprintf_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test4 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test4
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.c
new file mode 100644
index 0000000000..1d3fbbe2a8
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.c
@@ -0,0 +1,71 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test4.c
+**
+** Purpose: Test #4 for the vfprintf function. Tests the pointer
+** specifier (%p).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ void *ptr = (void*) 0x123456;
+ INT64 lptr = I64(0x1234567887654321);
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+/*
+** Run only on 64 bit platforms
+*/
+#if defined(BIT64) && defined(PLATFORM_UNIX)
+ Trace("Testing for 64 Bit Platforms \n");
+ DoPointerTest("%p", NULL, "NULL", "0000000000000000");
+ DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
+ DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456");
+ DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456");
+ DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 ");
+ DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456");
+ DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456");
+ DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456");
+ DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456");
+ DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456");
+ DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321",
+ "1234567887654321");
+
+#else
+ Trace("Testing for Non 64 Bit Platforms \n");
+ DoPointerTest("%p", NULL, "NULL", "00000000");
+ DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456");
+ DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456");
+ DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456");
+ DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 ");
+ DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456");
+ DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456");
+ DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456");
+ DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456");
+ DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456");
+ DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321",
+ "1234567887654321");
+
+#endif
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat
new file mode 100644
index 0000000000..79b8a34522
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test4
+Description
+= Tests vfprintf with pointers
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt
new file mode 100644
index 0000000000..50fa2df8db
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test5.c
+)
+
+add_executable(paltest_vfprintf_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test5 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test5
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.c
new file mode 100644
index 0000000000..ed371c6da7
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.c
@@ -0,0 +1,61 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test5.c
+**
+** Purpose: Test #5 for the vfprintf function. Tests the count specifier (%n).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ char *longStr =
+ "really-long-string-that-just-keeps-going-on-and-on-and-on.."
+ "..................useless-filler.................................."
+ "..................useless-filler.................................."
+ "..................useless-filler.................................."
+ "%n bar";
+ char *longResult =
+ "really-long-string-that-just-keeps-going-on-and-on-and-on.."
+ "..................useless-filler.................................."
+ "..................useless-filler.................................."
+ "..................useless-filler.................................."
+ " bar";
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ DoCountTest("foo %n bar", 4, "foo bar");
+ DoCountTest(longStr, 257, longResult);
+ DoCountTest("fo%n bar", 2, "fo bar");
+ DoCountTest("%n ", 0, " ");
+ DoCountTest("foo %#n bar", 4, "foo bar");
+ DoCountTest("foo % n bar", 4, "foo bar");
+ DoCountTest("foo %+n bar", 4, "foo bar");
+ DoCountTest("foo %-n bar", 4, "foo bar");
+ DoCountTest("foo %0n bar", 4, "foo bar");
+ DoShortCountTest("foo %hn bar", 4, "foo bar");
+ DoCountTest("foo %ln bar", 4, "foo bar");
+ DoCountTest("foo %Ln bar", 4, "foo bar");
+ DoCountTest("foo %I64n bar", 4, "foo bar");
+ DoCountTest("foo %20.3n bar", 4, "foo bar");
+
+ PAL_Terminate();
+
+ return PASS;
+}
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat
new file mode 100644
index 0000000000..e4c11e48f0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test5
+Description
+= Tests vfprintf with the count specifier
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt
new file mode 100644
index 0000000000..d7ba1b4bb0
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test6.c
+)
+
+add_executable(paltest_vfprintf_test6
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test6 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test6
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.c
new file mode 100644
index 0000000000..c0838310f3
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.c
@@ -0,0 +1,49 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test6.c
+**
+** Purpose: Test #6 for the vfprintf function. Tests the char specifier (%c).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ WCHAR wc = (WCHAR) 'c';
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoCharTest("foo %c", 'b', "foo b");
+ DoCharTest("foo %hc", 'b', "foo b");
+ DoWCharTest("foo %lc", wc, "foo c");
+ DoCharTest("foo %Lc", 'b', "foo b");
+ DoCharTest("foo %I64c", 'b', "foo b");
+ DoCharTest("foo %5c", 'b', "foo b");
+ DoCharTest("foo %.0c", 'b', "foo b");
+ DoCharTest("foo %-5c", 'b', "foo b ");
+ DoCharTest("foo %05c", 'b', "foo 0000b");
+ DoCharTest("foo % c", 'b', "foo b");
+ DoCharTest("foo %#c", 'b', "foo b");
+
+ PAL_Terminate();
+ return PASS;
+}
+
+
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat
new file mode 100644
index 0000000000..9863680451
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test6
+Description
+= Tests vfprintf with characters
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt
new file mode 100644
index 0000000000..9e3b8d3a04
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test7.c
+)
+
+add_executable(paltest_vfprintf_test7
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test7 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test7
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.c
new file mode 100644
index 0000000000..7e4b4eb172
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.c
@@ -0,0 +1,48 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test7.c
+**
+** Purpose: Test #7 for the vfprintf function. Tests the wide char
+** specifier (%C).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ WCHAR wb = (WCHAR) 'b';
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoWCharTest("foo %C", wb, "foo b");
+ DoWCharTest("foo %hC", wb, "foo b");
+ DoCharTest("foo %lC", 'c', "foo c");
+ DoWCharTest("foo %LC", wb, "foo b");
+ DoWCharTest("foo %I64C", wb, "foo b");
+ DoWCharTest("foo %5C", wb, "foo b");
+ DoWCharTest("foo %.0C", wb, "foo b");
+ DoWCharTest("foo %-5C", wb, "foo b ");
+ DoWCharTest("foo %05C", wb, "foo 0000b");
+ DoWCharTest("foo % C", wb, "foo b");
+ DoWCharTest("foo %#C", wb, "foo b");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat
new file mode 100644
index 0000000000..752f6dba80
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test7
+Description
+= Tests vfprintf with wide characters
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt
new file mode 100644
index 0000000000..36e46241e2
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test8.c
+)
+
+add_executable(paltest_vfprintf_test8
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test8 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test8
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.c
new file mode 100644
index 0000000000..bc6084f3e6
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.c
@@ -0,0 +1,54 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test8.c
+**
+** Purpose: Test #8 for the vfprintf function. Tests the decimal
+** specifier (%d).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int neg = -42;
+ int pos = 42;
+ INT64 l = 42;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoNumTest("foo %d", pos, "foo 42");
+ DoNumTest("foo %ld", 0xFFFF, "foo 65535");
+ DoNumTest("foo %hd", 0xFFFF, "foo -1");
+ DoNumTest("foo %Ld", pos, "foo 42");
+ DoI64Test("foo %I64d", l, "42", "foo 42");
+ DoNumTest("foo %3d", pos, "foo 42");
+ DoNumTest("foo %-3d", pos, "foo 42 ");
+ DoNumTest("foo %.1d", pos, "foo 42");
+ DoNumTest("foo %.3d", pos, "foo 042");
+ DoNumTest("foo %03d", pos, "foo 042");
+ DoNumTest("foo %#d", pos, "foo 42");
+ DoNumTest("foo %+d", pos, "foo +42");
+ DoNumTest("foo % d", pos, "foo 42");
+ DoNumTest("foo %+d", neg, "foo -42");
+ DoNumTest("foo % d", neg, "foo -42");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat
new file mode 100644
index 0000000000..4160454f04
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test8
+Description
+= Tests vfprintf with decimal numbers
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt
new file mode 100644
index 0000000000..5119c111d3
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test9.c
+)
+
+add_executable(paltest_vfprintf_test9
+ ${SOURCES}
+)
+
+add_dependencies(paltest_vfprintf_test9 CoreClrPal)
+
+target_link_libraries(paltest_vfprintf_test9
+ pthread
+ rt
+ m
+ CoreClrPal
+)
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.c b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.c
new file mode 100644
index 0000000000..ec31dd2590
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.c
@@ -0,0 +1,54 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: test9.c
+**
+** Purpose: Test #9 for the vfprintf function. Tests the integer
+** specifier (%i).
+**
+**
+**==========================================================================*/
+
+
+
+#include <palsuite.h>
+#include "../vfprintf.h"
+
+
+
+int __cdecl main(int argc, char *argv[])
+{
+ int neg = -42;
+ int pos = 42;
+ INT64 l = 42;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+
+ DoNumTest("foo %i", pos, "foo 42");
+ DoNumTest("foo %li", 0xFFFF, "foo 65535");
+ DoNumTest("foo %hi", 0xFFFF, "foo -1");
+ DoNumTest("foo %Li", pos, "foo 42");
+ DoI64Test("foo %I64i", l, "42", "foo 42");
+ DoNumTest("foo %3i", pos, "foo 42");
+ DoNumTest("foo %-3i", pos, "foo 42 ");
+ DoNumTest("foo %.1i", pos, "foo 42");
+ DoNumTest("foo %.3i", pos, "foo 042");
+ DoNumTest("foo %03i", pos, "foo 042");
+ DoNumTest("foo %#i", pos, "foo 42");
+ DoNumTest("foo %+i", pos, "foo +42");
+ DoNumTest("foo % i", pos, "foo 42");
+ DoNumTest("foo %+i", neg, "foo -42");
+ DoNumTest("foo % i", neg, "foo -42");
+
+ PAL_Terminate();
+ return PASS;
+}
+
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat
new file mode 100644
index 0000000000..735efd2074
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat
@@ -0,0 +1,12 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = vfprintf
+Name = Positive Test for vfprintf
+TYPE = DEFAULT
+EXE1 = test9
+Description
+= Tests vfprintf with integer numbers
diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h b/src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h
new file mode 100644
index 0000000000..44f84050d5
--- /dev/null
+++ b/src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h
@@ -0,0 +1,464 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*============================================================================
+**
+** Source: vfprintf.h
+**
+** Purpose: Contains common testing functions for vfprintf
+**
+**
+**==========================================================================*/
+
+#ifndef __vfprintf_H__
+#define __vfprintf_H__
+
+int DoVfprintf(FILE *fp, char *format, ...)
+{
+ int retVal;
+ va_list arglist;
+
+ va_start(arglist, format);
+ retVal = vfprintf(fp, format, arglist);
+ va_end(arglist);
+
+ return (retVal);
+}
+
+void DoStrTest(char *formatstr, char* param, char *checkstr)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+ if ((DoVfprintf(fp, formatstr, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ param, formatstr, checkstr, buf);
+ }
+ fclose(fp);
+}
+
+void DoWStrTest(char *formatstr, WCHAR* param, char *checkstr)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+ if ((DoVfprintf(fp, formatstr, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert wide string \"%S\" into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ param, formatstr, checkstr, buf);
+ }
+ fclose(fp);
+}
+
+
+void DoPointerTest(char *formatstr, void* param, char* paramstr,
+ char *checkstr1)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+
+ if ((DoVfprintf(fp, formatstr, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert %s into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ paramstr, formatstr, checkstr1, buf);
+ }
+
+ if ((fclose( fp )) != 0)
+ {
+ Fail("ERROR: fclose failed to close \"testfile.txt\"\n");
+ }
+}
+
+
+
+void DoCountTest(char *formatstr, int param, char *checkstr)
+{
+ FILE *fp;
+ char buf[512] = { 0 };
+ int n = -1;
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+
+ if ((DoVfprintf(fp, formatstr, &n)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+
+ if ((fgets(buf, sizeof(buf), fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (n != param)
+ {
+ Fail("ERROR: Expected count parameter to resolve to %d, got %X\n",
+ param, n);
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf);
+ }
+
+ if ((fclose( fp )) != 0)
+ {
+ Fail("ERROR: fclose failed to close \"testfile.txt\"\n");
+ }
+}
+
+void DoShortCountTest(char *formatstr, int param, char *checkstr)
+{
+ FILE *fp;
+ char buf[512] = { 0 };
+ short int n = -1;
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+
+ if ((DoVfprintf(fp, formatstr, &n)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (n != param)
+ {
+ Fail("ERROR: Expected count parameter to resolve to %d, got %X\n",
+ param, n);
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf);
+ }
+
+ if ((fclose( fp )) != 0)
+ {
+ Fail("ERROR: fclose failed to close \"testfile.txt\"\n");
+ }
+}
+
+
+void DoCharTest(char *formatstr, char param, char *checkstr)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+ if ((DoVfprintf(fp, formatstr, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ param, param, formatstr, checkstr, buf);
+ }
+ fclose(fp);
+}
+
+void DoWCharTest(char *formatstr, WCHAR param, char *checkstr)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+ if ((DoVfprintf(fp, formatstr, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ (char)param, param, formatstr, checkstr, buf);
+ }
+ fclose(fp);
+}
+
+void DoNumTest(char *formatstr, int value, char *checkstr)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+ if ((DoVfprintf(fp, formatstr, value)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert %#x into \"%s\"\n"
+ "Expected \"%s\" got \"%s\".\n",
+ value, formatstr, checkstr, buf);
+ }
+ fclose(fp);
+}
+
+void DoI64Test(char *formatstr, INT64 value, char *valuestr, char *checkstr1)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+ if ((DoVfprintf(fp, formatstr, value)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert %s into \"%s\"\n"
+ "Expected \"%s\", got \"%s\".\n",
+ valuestr, formatstr, checkstr1, buf);
+ }
+ fclose(fp);
+}
+
+void DoDoubleTest(char *formatstr, double value, char *checkstr1,
+ char *checkstr2)
+{
+ FILE *fp;
+ char buf[256] = { 0 };
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+
+ if ((DoVfprintf(fp, formatstr, value)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
+ memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert %f into \"%s\"\n"
+ "Expected \"%s\" or \"%s\", got \"%s\".\n",
+ value, formatstr, checkstr1, checkstr2, buf);
+ }
+ fclose(fp);
+}
+
+
+void DoArgumentPrecTest(char *formatstr, int precision, void *param,
+ char *paramstr, char *checkstr1, char *checkstr2)
+{
+ FILE *fp;
+ char buf[256];
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+
+ if ((DoVfprintf(fp, formatstr, precision, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
+ memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n"
+ "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr,
+ precision, checkstr1, checkstr2, buf);
+ }
+
+
+ if ((fclose( fp )) != 0)
+ {
+ Fail("ERROR: fclose failed to close \"testfile.txt\"\n");
+ }
+
+}
+
+void DoArgumentPrecDoubleTest(char *formatstr, int precision, double param,
+ char *checkstr1, char *checkstr2)
+{
+ FILE *fp;
+ char buf[256];
+
+ if ((fp = fopen("testfile.txt", "w+")) == NULL )
+ {
+ Fail("ERROR: fopen failed to create testfile\n");
+ }
+
+ if ((DoVfprintf(fp, formatstr, precision, param)) < 0)
+ {
+ Fail("ERROR: vfprintf failed\n");
+ }
+
+ if ((fseek(fp, 0, SEEK_SET)) != 0)
+ {
+ Fail("ERROR: fseek failed\n");
+ }
+
+ if ((fgets(buf, 100, fp)) == NULL)
+ {
+ Fail("ERROR: fgets failed\n");
+ }
+
+ if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 &&
+ memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0)
+ {
+ Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n"
+ "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr,
+ precision, checkstr1, checkstr2, buf);
+ }
+
+ if ((fclose( fp )) != 0)
+ {
+ Fail("ERROR: fclose failed to close \"testfile.txt\"\n");
+ }
+
+}
+
+#endif
+