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 (iswdigit)
8**
9** Purpose: Tests the PAL implementation of the iswdigit function.
10** Tests the passed parameter to iswdigit for being a
11** digit ('0' - '9'). Also passes non-digits to make sure
12** iswdigit picks them up.
13** NOTE: There are three ASCII values that under Windows,
14** iswdigit will return non-zero, indicating a digit.
15** These values are quite apparently not digits:
16** 178, 179, 185.
17** These are not tested.
18**
19**
20**===================================================================*/
21
22#include <palsuite.h>
23
24int __cdecl main(int argc, char **argv)
25{
26
27 int result;
28 int i;
29
30 wchar_t passTestCases[] = {'1','2','3','4','5','6','7','8','9'};
31 wchar_t failTestCases[] = {'a','b','p','$','?',234};
32
33 if ((PAL_Initialize(argc, argv)) != 0)
34 {
35 return (FAIL);
36 }
37
38 /* Loop through each case. Testing if each is a digit. */
39 for(i = 0; i < sizeof(passTestCases) / sizeof(wchar_t); i++)
40 {
41 result = iswdigit(passTestCases[i]);
42
43 /* The return value is 'non-zero' indicates digit*/
44 if (result == 0)
45 {
46 Fail("ERROR: iswdigit returned \"%d\" instead indicating"
47 " \"%c\" is not a digit\n",
48 result,
49 passTestCases[i]);
50 }
51 }
52
53 /* Loop through each case. Testing if each is a not a digit. */
54 for(i = 0; i < sizeof(failTestCases) / sizeof(wchar_t); i++)
55 {
56 result = iswdigit(failTestCases[i]);
57
58 /* The return value is 'zero' indicates non-digit*/
59 if (result != 0)
60 {
61 Fail("ERROR: iswdigit returned \"%d\", indicating"
62 " \"%c\" is a digit\n",
63 result,
64 failTestCases[i]);
65 }
66 }
67 PAL_Terminate();
68 return (PASS);
69}
70