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: test6.c |
8 | ** |
9 | ** Purpose: Test #6 for the wcstoul function. Tests strings with octal/hex |
10 | ** number specifers |
11 | ** |
12 | ** |
13 | **==========================================================================*/ |
14 | #include <palsuite.h> |
15 | |
16 | |
17 | /* |
18 | * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, |
19 | * this is not currently tested. |
20 | */ |
21 | |
22 | |
23 | int __cdecl main(int argc, char *argv[]) |
24 | { |
25 | WCHAR test1[] = {'0','x','1','2', 0}; |
26 | WCHAR test2[] = {'0','1','2',0}; |
27 | WCHAR *end; |
28 | ULONG l; |
29 | |
30 | if (0 != PAL_Initialize(argc, argv)) |
31 | { |
32 | return FAIL; |
33 | } |
34 | |
35 | |
36 | l = wcstoul(test1, &end, 16); |
37 | if (l != 0x12) |
38 | { |
39 | Fail("ERROR: Expected wcstoul to return %u, got %u\n" , 0x12, l); |
40 | } |
41 | if (end != test1 + 4) |
42 | { |
43 | Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n" , |
44 | test1 + 4, end); |
45 | } |
46 | |
47 | l = wcstoul(test1, &end, 10); |
48 | if (l != 0) |
49 | { |
50 | Fail("ERROR: Expected wcstoul to return %u, got %u\n" , 0, l); |
51 | } |
52 | if (end != test1+1) |
53 | { |
54 | Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n" , |
55 | test1+1, end); |
56 | } |
57 | |
58 | l = wcstoul(test2, &end, 8); |
59 | if (l != 10) |
60 | { |
61 | Fail("ERROR: Expected wcstoul to return %u, got %u\n" , 10, l); |
62 | } |
63 | if (end != test2 + 3) |
64 | { |
65 | Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n" , |
66 | test2 + 3, end); |
67 | } |
68 | |
69 | l = wcstoul(test2, &end, 10); |
70 | if (l != 12) |
71 | { |
72 | Fail("ERROR: Expected wcstoul to return %u, got %u\n" , 12, l); |
73 | } |
74 | |
75 | if (end != test2 + 3) |
76 | { |
77 | Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n" , |
78 | test2 + 3, end); |
79 | } |
80 | |
81 | PAL_Terminate(); |
82 | return PASS; |
83 | } |
84 | |