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 that GetCPInfo works for CP_ACP and 0x4E4 (default codepage)
10** Also makes sure it correctly handles an invalid code page.
11**
12**
13**==========================================================================*/
14
15
16#include <palsuite.h>
17
18
19int __cdecl main(int argc, char *argv[])
20{
21 CPINFO cpinfo;
22
23 if (0 != PAL_Initialize(argc, argv))
24 {
25 return FAIL;
26 }
27
28 if (!GetCPInfo(CP_ACP, &cpinfo))
29 {
30 Fail("GetCPInfo() unable to get info for CP_ACP\n");
31 }
32
33 if (!GetCPInfo(65001, &cpinfo))
34 {
35 Fail("GetCPInfo() unable to get info for code page 65001 (utf8)\n");
36 }
37
38 if (GetCPInfo(-1, &cpinfo))
39 {
40 Fail("GetCPInfo() did not error on invalid code page!\n");
41 }
42
43 if (GetLastError() != ERROR_INVALID_PARAMETER)
44 {
45 Fail("GetCPInfo() failed to set the last error to"
46 " ERROR_INVALID_PARAMETER!\n");
47 }
48
49
50 PAL_Terminate();
51
52 return PASS;
53}
54
55