summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/c_runtime/iswprint/test1/test1.cpp
blob: 08a985b2d64a102bf48b02a7885171236108d996 (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
59
// 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: Tests iswprint with all wide characters, ensuring they are 
**          consistent with GetStringTypeExW.
**
**
**===================================================================*/

#include <palsuite.h>

int __cdecl main(int argc, char **argv)
{
    WORD Info;
    int ret;
    int i;
    WCHAR ch;

    if (PAL_Initialize(argc, argv))
    {
        return FAIL;
    }

    for (i=0; i<=0xFFFF; i++)
    {
        ch = i;
        ret = GetStringTypeExW(LOCALE_USER_DEFAULT, CT_CTYPE1, &ch, 1, &Info);
        if (!ret)
        {
            Fail("GetStringTypeExW failed to get information for %#X!\n", ch);
        }

        ret = iswprint(ch);
        if (Info & (C1_BLANK|C1_PUNCT|C1_ALPHA|C1_DIGIT))
        {
            if (!ret)
            {
                Fail("iswprint returned incorrect results for %#X: "
                    "expected printable\n", ch);
            }
        }
        else
        {
            if (ret)
            {
                Fail("iswprint returned incorrect results for %#X: "
                    "expected non-printable\n", ch);
            }
        }
    }

    PAL_Terminate();
    return PASS;
}