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: |
10 | ** Check a character set against a string to see that the function returns |
11 | ** the length of the substring which consists of all characters in the string. |
12 | ** Also check that if the character set doesn't match the string at all, that |
13 | ** the value is 0. |
14 | ** |
15 | ** |
16 | **==========================================================================*/ |
17 | |
18 | #include <palsuite.h> |
19 | |
20 | struct testCase |
21 | { |
22 | long result; |
23 | char *string1; |
24 | char *string2; |
25 | }; |
26 | |
27 | int __cdecl main(int argc, char *argv[]) |
28 | { |
29 | int i=0; |
30 | long TheResult = 0; |
31 | |
32 | struct testCase testCases[]= |
33 | { |
34 | {4,"abcdefg12345678hijklmnopqrst" ,"a2bjk341cd" }, |
35 | {14,"This is a test, testing" , "aeioTts rh" }, |
36 | {0,"foobar" ,"kpzt" } |
37 | }; |
38 | |
39 | /* |
40 | * Initialize the PAL |
41 | */ |
42 | if (0 != PAL_Initialize(argc, argv)) |
43 | { |
44 | return FAIL; |
45 | } |
46 | |
47 | for (i=0; i<sizeof(testCases)/sizeof(struct testCase);i++) |
48 | { |
49 | TheResult = strspn(testCases[i].string1,testCases[i].string2); |
50 | if (TheResult != testCases[i].result) |
51 | { |
52 | Fail("Expected strspn to return %d, got %d!\n" , |
53 | testCases[i].result,TheResult); |
54 | } |
55 | |
56 | } |
57 | |
58 | PAL_Terminate(); |
59 | return PASS; |
60 | } |
61 | |