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: test4.c
8**
9** Purpose: Tests swprintf with pointers
10**
11**
12**==========================================================================*/
13
14
15
16#include <palsuite.h>
17#include "../swprintf.h"
18
19/*
20 * Uses memcmp & wcslen
21 */
22
23
24int __cdecl main(int argc, char *argv[])
25{
26 void *ptr = (void*) 0x123456;
27 INT64 lptr = I64(0x1234567887654321);
28
29 if (PAL_Initialize(argc, argv) != 0)
30 {
31 return FAIL;
32 }
33/*
34** Run only on 64 bit platforms
35*/
36#if defined(BIT64)
37 Trace("Testing for 64 Bit Platforms \n");
38 DoPointerTest(convert("%p"), NULL, convert("0000000000000000"));
39 DoPointerTest(convert("%p"), ptr, convert("0000000000123456"));
40 DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456"));
41 DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456"));
42 DoPointerTest(convert("%-17p"), ptr, convert("0000000000123456 "));
43 DoPointerTest(convert("%+p"), ptr, convert("0000000000123456"));
44 DoPointerTest(convert("% p"), ptr, convert("0000000000123456"));
45 DoPointerTest(convert("%#p"), ptr, convert("0X0000000000123456"));
46 DoPointerTest(convert("%lp"), ptr, convert("00123456"));
47 DoPointerTest(convert("%hp"), ptr, convert("00003456"));
48 DoPointerTest(convert("%Lp"), ptr, convert("00123456"));
49 DoI64Test(convert("%I64p"), lptr, "pointer to 0X1234567887654321",
50 convert("1234567887654321"));
51#else
52 Trace("Testing for Non 64 Bit Platforms \n");
53 DoPointerTest(convert("%p"), NULL, convert("00000000"));
54 DoPointerTest(convert("%p"), ptr, convert("00123456"));
55 DoPointerTest(convert("%9p"), ptr, convert(" 00123456"));
56 DoPointerTest(convert("%09p"), ptr, convert(" 00123456"));
57 DoPointerTest(convert("%-9p"), ptr, convert("00123456 "));
58 DoPointerTest(convert("%+p"), ptr, convert("00123456"));
59 DoPointerTest(convert("% p"), ptr, convert("00123456"));
60 DoPointerTest(convert("%#p"), ptr, convert("0X00123456"));
61 DoPointerTest(convert("%lp"), ptr, convert("00123456"));
62 DoPointerTest(convert("%hp"), ptr, convert("00003456"));
63 DoPointerTest(convert("%Lp"), ptr, convert("00123456"));
64 DoI64Test(convert("%I64p"), lptr, "pointer to 0X1234567887654321",
65 convert("1234567887654321"));
66#endif
67
68 PAL_Terminate();
69 return PASS;
70}
71
72