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