summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/isxdigit/test1/test1.cpp
blob: be25af233ceae1502bc438fc4f2f7455c00b6341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*============================================================================
**
** Source:  test1.c
**
** Purpose: Run through every possible character.  For each time that 
** isxdigit returns:
** 1, check through a list of the known hex characters to ensure that it
** is really a hex char.  Also, when it returns 0, ensure that that character
** isn't a hex character.
**
**
**==========================================================================*/



#include <palsuite.h>


int __cdecl main(int argc, char *argv[])
{
    int i;

    /* Initialize the PAL */
    if ( 0 != PAL_Initialize(argc, argv))
    {
        return FAIL;
    }


    /* Loop through each character and call isxdigit for each character */
    for (i=1; i<256; i++)
    {

        if (isxdigit(i) == 0)
        {
            if( ((i>=48) && (i<=57)) || ((i>=97) && (i<=102)) ||
                ((i>=65) && (i<=70)) )
            {
                Fail("ERROR: isxdigit() returns true for '%c' (%d)\n", i, i);
            }
        }
        else
        {
            if( ((i<48) && (i>58)) || ((i<97) && (i>102)) ||
                ((i<65) && (i>70)) )
            {
                Fail("ERROR: isxdigit() returns false for '%c' (%d)\n", i, i);
            }
        }
    }

    PAL_Terminate();
    return PASS;
}