| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | /*============================================================================ |
| 6 | ** |
| 7 | ** Source: test1.c |
| 8 | ** |
| 9 | ** Purpose: Tests strcspn with a character set that should give an index into |
| 10 | ** the middle of the original string. Also tests with character sets |
| 11 | ** that are not in the string at all, and character sets that match |
| 12 | ** with the very first character. |
| 13 | ** |
| 14 | ** |
| 15 | **==========================================================================*/ |
| 16 | |
| 17 | #include <palsuite.h> |
| 18 | |
| 19 | struct testCase |
| 20 | { |
| 21 | long result; |
| 22 | char *string1; |
| 23 | char *string2; |
| 24 | }; |
| 25 | |
| 26 | int __cdecl main(int argc, char *argv[]) |
| 27 | { |
| 28 | int i=0; |
| 29 | long TheResult = 0; |
| 30 | |
| 31 | struct testCase testCases[]= |
| 32 | { |
| 33 | {4,"abcdefg12345678hijklmnopqrst" ,"t8m1sBe" }, |
| 34 | {23,"This is a test, testing" , "X\tylM" }, |
| 35 | {0,"foobar" ,"tzkfb" }, |
| 36 | }; |
| 37 | |
| 38 | /* |
| 39 | * Initialize the PAL |
| 40 | */ |
| 41 | if (0 != PAL_Initialize(argc, argv)) |
| 42 | { |
| 43 | return FAIL; |
| 44 | } |
| 45 | |
| 46 | for (i=0; i<sizeof(testCases)/sizeof(struct testCase); i++) |
| 47 | { |
| 48 | TheResult = strcspn(testCases[i].string1,testCases[i].string2); |
| 49 | if (TheResult != testCases[i].result) |
| 50 | { |
| 51 | Fail("Expected strcspn to return %d, got %d!\n" , |
| 52 | testCases[i].result,TheResult); |
| 53 | } |
| 54 | |
| 55 | } |
| 56 | |
| 57 | PAL_Terminate(); |
| 58 | return PASS; |
| 59 | } |
| 60 | |