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