diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/c_runtime/isprint | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2 coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/isprint')
7 files changed, 169 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/isprint/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isprint/CMakeLists.txt new file mode 100644 index 0000000000..ef14ea5352 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test2) + diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isprint/test1/CMakeLists.txt new file mode 100644 index 0000000000..365777ab5a --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + isprint.c +) + +add_executable(paltest_isprint_test1 + ${SOURCES} +) + +add_dependencies(paltest_isprint_test1 coreclrpal) + +target_link_libraries(paltest_isprint_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test1/isprint.c b/src/pal/tests/palsuite/c_runtime/isprint/test1/isprint.c new file mode 100644 index 0000000000..54db666bf2 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/test1/isprint.c @@ -0,0 +1,42 @@ +// 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: isprint.c +** +** Purpose: Positive test the isprint API. +** Call isprint to test if a character is printable +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + int index; + + /*Initialize the PAL environment*/ + err = PAL_Initialize(argc, argv); + if(0 != err) + { + return FAIL; + } + + /*check if the character is printable*/ + for(index = 0x20; index<=0x7E;index++) + { + err = isprint(index); + if(0 == err) + { + Fail("\nFailed to call isprint API to check " + "printable character from 0x20 to 0x7E!\n"); + } + } + + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isprint/test1/testinfo.dat new file mode 100644 index 0000000000..c9b9ec07ea --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/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 = miscellaneous +Function = isprint +Name = Positive test for isprint API to check if a character is printable +TYPE = DEFAULT +EXE1 = isprint +Description +=Test the isprint to check if a character is printable diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isprint/test2/CMakeLists.txt new file mode 100644 index 0000000000..a7ad75cc04 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/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_isprint_test2 + ${SOURCES} +) + +add_dependencies(paltest_isprint_test2 coreclrpal) + +target_link_libraries(paltest_isprint_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test2/test2.c b/src/pal/tests/palsuite/c_runtime/isprint/test2/test2.c new file mode 100644 index 0000000000..2170c47a14 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/test2/test2.c @@ -0,0 +1,59 @@ +// 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: isprint.c +** +** Purpose: Negative test for the isprint API. Call isprint +** to test if out of range characters are +** not printable. +** +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + + /*Initialize the PAL environment*/ + err = PAL_Initialize(argc, argv); + if(0 != err) + { + return FAIL; + } + + /*check that function fails for values that are not printable*/ + err = isprint(0x15); + if(err) + { + Fail("\nSucceeded when it should have failed because 0x15 " + "is not in the range of printable characters\n"); + } + + err = isprint(0xAA); + if(err) + { + Fail("\nSucceeded when it should have failed because 0xAA " + "is not in the range of printable characters\n"); + } + + /* check carriage return */ + if(0 != isprint(0x0d)) + { + Fail("\nSucceeded when it should have failed because 0x0d " + "is not in the range of printable characters\n"); + } + + /* check line feed */ + if(0 != isprint(0x0a)) + { + Fail("\nSucceeded when it should have failed because 0x0a " + "is not in the range of printable characters\n"); + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isprint/test2/testinfo.dat new file mode 100644 index 0000000000..e115278edb --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isprint/test2/testinfo.dat @@ -0,0 +1,13 @@ +# 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 = miscellaneous +Function = isprint +Name = Test isprint API to check if out of range characters are not printable. +TYPE = DEFAULT +EXE1 = test2 +Description +=Test the isprint function to verify that out of range characters +=are not printable. |