diff options
Diffstat (limited to 'src/pal/tests/palsuite/c_runtime/isspace')
4 files changed, 120 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/isspace/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isspace/CMakeLists.txt new file mode 100644 index 0000000000..f6aa0cb2d9 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isspace/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/isspace/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isspace/test1/CMakeLists.txt new file mode 100644 index 0000000000..34ad70d328 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isspace/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_isspace_test1 + ${SOURCES} +) + +add_dependencies(paltest_isspace_test1 coreclrpal) + +target_link_libraries(paltest_isspace_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/c_runtime/isspace/test1/test1.c b/src/pal/tests/palsuite/c_runtime/isspace/test1/test1.c new file mode 100644 index 0000000000..6cd1ce878b --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isspace/test1/test1.c @@ -0,0 +1,82 @@ +// 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: Test #1 for the isspace function +** +** +**==========================================================================*/ + + + +#include <palsuite.h> + +struct testCase +{ + long result; + char avalue; +}; + + + +int __cdecl main(int argc, char *argv[]) +{ + int i=0; + long result = 0; + + /* + * A structures of the testcases to be tested with + * isspace function + */ + struct testCase testCases[] = + { + {1,'\n'}, + {1,'\t'}, + {1,'\r'}, + {1,'\v'}, + {1,'\f'}, + {1,' '}, + {0,'a'}, + {0,'A'}, + {0,'z'}, + {0,'Z'}, + {0,'r'}, + {0,'R'}, + {0,'0'}, + {0,'*'}, + {0,3} + }; + + /* + * Initialize the PAL + */ + if ( 0 != PAL_Initialize(argc, argv)) + { + return FAIL; + } + + + /* Loop through the testcases */ + for (i=0; i<sizeof(testCases)/sizeof(struct testCase); i++) + { + result = isspace(testCases[i].avalue); + if ( ((testCases[i].result == 1) && (result==0)) || + ((testCases[i].result ==0) && (result !=0)) ) + { + Fail("ERROR: isspace() returned %d for %c instead of %d\n", + result, + testCases[i].avalue, + testCases[i].result ); + } + } + + + PAL_Terminate(); + + return PASS; +} + diff --git a/src/pal/tests/palsuite/c_runtime/isspace/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isspace/test1/testinfo.dat new file mode 100644 index 0000000000..fe9926e8c8 --- /dev/null +++ b/src/pal/tests/palsuite/c_runtime/isspace/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 = isspace +Name = Positive Test for isspace +TYPE = DEFAULT +EXE1 = test1 +Description += Run through every possible character. For each time that isspace returns += >0, check through a list of the known space characters to ensure that it += is really a space. Also, when it returns <=0, ensure that that character += isn't a space. |