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