| 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 (toupper) |
| 8 | ** |
| 9 | ** |
| 10 | ** Purpose: Tests the PAL implementation of the toupper function. |
| 11 | ** Check that the toupper function makes lower case |
| 12 | ** character a capital. Also check that it has no effect |
| 13 | ** on upper case letters and special characters. |
| 14 | ** |
| 15 | ** |
| 16 | **===================================================================*/ |
| 17 | |
| 18 | #include <palsuite.h> |
| 19 | |
| 20 | struct testCase |
| 21 | { |
| 22 | int upper; |
| 23 | int start; |
| 24 | }; |
| 25 | |
| 26 | int __cdecl main(int argc, char **argv) |
| 27 | { |
| 28 | |
| 29 | int result; |
| 30 | int i; |
| 31 | |
| 32 | struct testCase testCases[] = |
| 33 | { |
| 34 | {'A', 'a'}, /* Basic cases */ |
| 35 | {'Z', 'z'}, |
| 36 | {'B', 'B'}, /* Upper case */ |
| 37 | {'%', '%'}, /* Characters without case */ |
| 38 | {157, 157} |
| 39 | }; |
| 40 | |
| 41 | if ((PAL_Initialize(argc, argv)) != 0) |
| 42 | { |
| 43 | return FAIL; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | /* Loop through each case. Convert each character to upper case |
| 48 | and then compare to ensure that it is the correct value. |
| 49 | */ |
| 50 | for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) |
| 51 | { |
| 52 | /*Convert to upper case*/ |
| 53 | result = toupper(testCases[i].start); |
| 54 | |
| 55 | if (testCases[i].upper != result) |
| 56 | { |
| 57 | Fail("ERROR: toupper capitalized \"%c\" to %c instead of %c.\n" , |
| 58 | testCases[i].start, result, testCases[i].upper); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | PAL_Terminate(); |
| 63 | return PASS; |
| 64 | } |
| 65 | |