diff options
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/_getw')
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt | 19 | ||||
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat | bin | 0 -> 28 bytes | |||
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/_getw/test1/test1.c | 96 | ||||
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat | 15 |
5 files changed, 134 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt new file mode 100644 index 0000000000..f6aa0cb2d9 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_getw/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) + diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_getw/test1/CMakeLists.txt new file mode 100644 index 0000000000..d44477b232 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_getw/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_getw_test1 + ${SOURCES} +) + +add_dependencies(paltest_getw_test1 coreclrpal) + +target_link_libraries(paltest_getw_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat b/src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat Binary files differnew file mode 100644 index 0000000000..b20eae054c --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_getw/test1/test.dat diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_getw/test1/test1.c new file mode 100644 index 0000000000..34ce4ee7de --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_getw/test1/test1.c @@ -0,0 +1,96 @@ +// 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: Several integers are read from a previously written file +** using _getw. The test passes if the values read match those known to +** be in the file. +** +** +**==========================================================================*/ + +#include <palsuite.h> + +/*Tests _getw using a previously written data file */ +int __cdecl main(int argc, char **argv) +{ + const int testValues[] = + { + 0, + 1, + -1, + 0x7FFFFFFF, /* largest positive integer on 32 bit systems */ + 0x80000000, /* largest negative integer on 32 bit systems */ + 0xFFFFFFFF, + 0xFFFFAAAA + }; + + int i = 0; + int input = 0; + + const char filename[] = "test.dat"; + + + FILE *fp = NULL; + + /* + * Initialize the PAL and return FAIL if this fails + */ + if (0 != (PAL_Initialize(argc, argv))) + { + return FAIL; + } + + /* write the file that we will use to test */ + + + /* + Don't uncomment this code, it was used to create the data file + initially on windows, but if it is run on all test platforms, the + tests will always pass. + + fp = fopen(filename, "w"); + if (fp == NULL) + { + Fail("Unable to open file for write.\n"); + } + for (i = 0; i < sizeof(testValues) / sizeof(testValues[0]); i++) + { + _putw(testValues[i], fp); + } + + if (fclose(fp) != 0) + { + Fail("Error closing file after writing to it with _putw.\n"); + } + */ + + + /*Now read values back from the file and see if they match.*/ + fp = fopen(filename, "r"); + if (fp == NULL) + { + Fail ("Unable to open file for read.\n"); + } + for (i = 0; i < sizeof(testValues) / sizeof(testValues[0]); i++) + { + input = _getw(fp); + if (VAL32(input) != testValues[i]) + { + Fail ("_getw did not get the expected values when reading " + "from a file.\n"); + } + } + + if (fclose(fp) != 0) + { + Fail ("Error closing file after reading from it with _getw\n"); + } + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat new file mode 100644 index 0000000000..4044dadbcc --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/_getw/test1/testinfo.dat @@ -0,0 +1,15 @@ +# 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 = _getw +Name = Positive Test for _getw +TYPE = DEFAULT +EXE1 = test1 +Description +=Several integers are read from a previously written file +=using _getw. The test passes if the values read match those known to +=be in the file. + |