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 the PAL implementation of the isalpha function |
10 | ** Check that a number of characters return the correct |
11 | ** values for whether they are alpha or not. |
12 | ** |
13 | ** |
14 | **===================================================================*/ |
15 | |
16 | #include <palsuite.h> |
17 | |
18 | struct testCase |
19 | { |
20 | int CorrectResult; |
21 | int character; |
22 | }; |
23 | |
24 | int __cdecl main(int argc, char **argv) |
25 | { |
26 | |
27 | int result; |
28 | int i; |
29 | |
30 | struct testCase testCases[] = |
31 | { |
32 | {1, 'a'}, |
33 | {1, 'z'}, |
34 | {1, 'B'}, |
35 | {0, '5'}, |
36 | {0, '?'}, |
37 | {0, 230} |
38 | }; |
39 | |
40 | if (PAL_Initialize(argc, argv)) |
41 | { |
42 | return FAIL; |
43 | } |
44 | |
45 | |
46 | /* Loop through each case. Check to see if each is alpha or |
47 | not. |
48 | */ |
49 | |
50 | for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) |
51 | { |
52 | |
53 | result = isalpha(testCases[i].character); |
54 | |
55 | /* The return value is 'non-zero' for success. This if condition |
56 | * will still work if that non-zero isn't just 1 |
57 | */ |
58 | if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || |
59 | ( (testCases[i].CorrectResult == 0) && (result != 0) )) |
60 | { |
61 | Fail("ERROR: isalpha returned %i instead of %i for character " |
62 | "%c.\n" , |
63 | result, |
64 | testCases[i].CorrectResult, |
65 | testCases[i].character); |
66 | } |
67 | |
68 | } |
69 | |
70 | |
71 | PAL_Terminate(); |
72 | return PASS; |
73 | } |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |