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: test12.c
8**
9** Purpose: Test #12 for the printf function. Tests the (lowercase)
10** hexadecimal specifier (%x)
11**
12**
13**==========================================================================*/
14
15
16
17#include <palsuite.h>
18#include "../printf.h"
19
20
21int __cdecl main(int argc, char *argv[])
22{
23 int neg = -42;
24 int pos = 0x1234ab;
25 INT64 l = I64(0x1234567887654321);
26
27 if (PAL_Initialize(argc, argv))
28 {
29 return FAIL;
30 }
31
32
33 DoNumTest("foo %x", pos, "foo 1234ab");
34 DoNumTest("foo %lx", pos, "foo 1234ab");
35 DoNumTest("foo %hx", pos, "foo 34ab");
36 DoNumTest("foo %Lx", pos, "foo 1234ab");
37 DoI64Test("foo %I64x", l, "0x1234567887654321",
38 "foo 1234567887654321");
39 DoNumTest("foo %7x", pos, "foo 1234ab");
40 DoNumTest("foo %-7x", pos, "foo 1234ab ");
41 DoNumTest("foo %.1x", pos, "foo 1234ab");
42 DoNumTest("foo %.7x", pos, "foo 01234ab");
43 DoNumTest("foo %07x", pos, "foo 01234ab");
44 DoNumTest("foo %#x", pos, "foo 0x1234ab");
45 DoNumTest("foo %+x", pos, "foo 1234ab");
46 DoNumTest("foo % x", pos, "foo 1234ab");
47 DoNumTest("foo %+x", neg, "foo ffffffd6");
48 DoNumTest("foo % x", neg, "foo ffffffd6");
49
50 PAL_Terminate();
51 return PASS;
52}
53
54