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: test5.c
8**
9** Purpose: Test #5 for the wcstoul function
10**
11**
12**==========================================================================*/
13#include <palsuite.h>
14
15/*
16 * Notes: wcstoul should depend on the current locale's LC_NUMERIC category,
17 * this is not currently tested.
18 */
19
20
21int __cdecl main(int argc, char *argv[])
22{
23 WCHAR overstr[] = {'4','2','9','4','9','6','7','2','9','6',0};
24 WCHAR understr[] = {'-','1',0};
25 WCHAR *end;
26 ULONG l;
27
28 if (0 != PAL_Initialize(argc, argv))
29 {
30 return FAIL;
31 }
32
33 errno = 0;
34 l = wcstoul(overstr, &end, 10);
35
36 if (l != ULONG_MAX)
37 {
38 Fail("ERROR: Expected wcstoul to return %u, got %u\n", ULONG_MAX, l);
39 }
40 if (end != overstr + 10)
41 {
42 Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n",
43 overstr + 10, end);
44 }
45 if (errno != ERANGE)
46 {
47 Fail("ERROR: wcstoul did not set errno to ERANGE (%d)\n", errno);
48 }
49
50 errno = 0;
51 l = wcstoul(understr, &end, 10);
52
53 if (l != ULONG_MAX)
54 {
55 Fail("ERROR: Expected wcstoul to return %u, got %u\n", ULONG_MAX, l);
56 }
57 if (end != understr + 2)
58 {
59 Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n",
60 understr + 2, end);
61 }
62 if (errno != 0)
63 {
64 Fail("ERROR: wcstoul set errno to non-zero (%d)\n", errno);
65 }
66
67 PAL_Terminate();
68 return PASS;
69}
70