summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.c
blob: 0994940a57850cea814ac06d60b4678891b9683e (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// 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 that GetLocaleInfoW gives the correction information for 
**          LOCALE_NEUTRAL.
**
**
**==========================================================================*/

#include <palsuite.h>


int Types[] = { LOCALE_SDECIMAL, LOCALE_STHOUSAND, LOCALE_ILZERO, 
    LOCALE_SCURRENCY, LOCALE_SMONDECIMALSEP, LOCALE_SMONTHOUSANDSEP };

char *TypeStrings[] = { "LOCALE_SDECIMAL", "LOCALE_STHOUSAND", "LOCALE_ILZERO",
    "LOCALE_SCURRENCY", "LOCALE_SMONDECIMALSEP", "LOCALE_SMONTHOUSANDSEP" };

#define NUM_TYPES (sizeof(Types) / sizeof(Types[0]))

typedef WCHAR InfoStrings[NUM_TYPES][4];

typedef struct
{
    LCID lcid;
    InfoStrings Strings;
} LocalInfoType;

LocalInfoType Locales[] =
{
    {LOCALE_NEUTRAL, 
        {{'.',0}, {',',0}, {'1',0}, {'$',0}, {'.',0}, {',',0}}},
};

int NumLocales = sizeof(Locales) / sizeof(Locales[0]);


int __cdecl main(int argc, char *argv[])
{    
    WCHAR buffer[256] = { 0 };
    int ret;
    int i,j;

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

    for (i=0; i<NumLocales; i++)
    {
        for (j=0; j<NUM_TYPES; j++)
        {
            ret = GetLocaleInfoW(Locales[i].lcid, Types[j], buffer, 256);
            
            if (ret == 0)
            {
                Fail("GetLocaleInfoW returned an unexpected error!\n");
            }


            if (wcscmp(buffer, Locales[i].Strings[j]) != 0)
            {

                Fail("GetLocaleInfoW gave incorrect result for %s, "
                    "locale %#x:\nExpected \"%S\", got \"%S\"!\n", TypeStrings[j], 
                    Locales[i].lcid, Locales[i].Strings[j], buffer);
                    
            }

            if (ret != wcslen(Locales[i].Strings[j]) + 1)
            {
                Fail("GetLocaleInfoW returned incorrect value for %s, "
                    "locale %#x:\nExpected %d, got %d!\n", TypeStrings[j], 
                    Locales[i].lcid, wcslen(Locales[i].Strings[j])+1, ret);
            }
        }        
    }
    

    PAL_Terminate();

    return PASS;
}