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: wprintf.h
8**
9** Purpose: Containts common testing functions for wprintf
10**
11**
12**==========================================================================*/
13
14#ifndef __wprintf_H__
15#define __wprintf_H__
16
17void DoStrTest(const WCHAR *formatstr, const WCHAR *param, const WCHAR *checkstr)
18{
19 int ret;
20
21 ret = wprintf(formatstr, param);
22 if (ret != wcslen(checkstr))
23 {
24 Fail("DoStrTest:Expected wprintf to return %d, got %d.\n",
25 wcslen(checkstr), ret);
26 }
27}
28
29
30void DoPointerTest(const WCHAR *formatstr, void* param, WCHAR* paramstr,
31 const WCHAR *checkstr1)
32{
33 int ret;
34
35 ret = wprintf(formatstr, param);
36 if (ret != wcslen(checkstr1))
37 {
38 Fail("DoPointerTest:Expected wprintf to return %d, got %d.\n",
39 wcslen(checkstr1), ret);
40 }
41}
42
43void DoCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr)
44{
45 int ret;
46 int n = -1;
47
48 ret = wprintf(formatstr, &n);
49
50 if (n != param)
51 {
52 Fail("DoCountTest:Expected count parameter to resolve to %d, got %d\n", param, n);
53 }
54
55 if (ret != wcslen(checkstr))
56 {
57 Fail("DoCountTest:Expected wprintf to return %d, got %d.\n",
58 wcslen(checkstr), ret);
59 }
60}
61
62void DoShortCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr)
63{
64 int ret;
65 short int n = -1;
66
67 ret = wprintf(formatstr, &n);
68
69 if (n != param)
70 {
71 Fail("DoShortCountTest:Expected count parameter to resolve to %d, got %d\n", param, n);
72 }
73
74 if (ret != wcslen(checkstr))
75 {
76 Fail("DoShortCountTest:Expected wprintf to return %d, got %d.\n",
77 wcslen(checkstr), ret);
78 }
79}
80
81
82void DoCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr)
83{
84 int ret;
85
86 ret = wprintf(formatstr, param);
87 if (ret != wcslen(checkstr))
88 {
89 Fail("DoCharTest:Expected wprintf to return %d, got %d.\n",
90 wcslen(checkstr), ret);
91 }
92}
93
94void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr)
95{
96 int ret;
97
98 ret = wprintf(formatstr, param);
99 if (ret != wcslen(checkstr))
100 {
101 Fail("DoWCharTest:Expected wprintf to return %d, got %d.\n",
102 wcslen(checkstr), ret);
103 }
104}
105
106void DoNumTest(const WCHAR *formatstr, int param, const WCHAR *checkstr)
107{
108 int ret;
109
110 ret = wprintf(formatstr, param);
111 if (ret != wcslen(checkstr))
112 {
113 Fail("DoNumTest:Expected wprintf to return %d, got %d.\n",
114 wcslen(checkstr), ret);
115 }
116}
117
118void DoI64Test(const WCHAR *formatstr, INT64 param, const WCHAR *valuestr,
119 const WCHAR *checkstr1)
120{
121 int ret;
122
123 ret = wprintf(formatstr, param);
124 if (ret != wcslen(checkstr1))
125 {
126 Fail("DoI64Test:Expected wprintf to return %d, got %d.\n",
127 wcslen(checkstr1), ret);
128 }
129}
130
131void DoDoubleTest(const WCHAR *formatstr, double param,
132 const WCHAR *checkstr1, const WCHAR *checkstr2)
133{
134 int ret;
135
136 ret = wprintf(formatstr, param);
137 if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2))
138 {
139 Fail("DoDoubleTest:Expected wprintf to return %d or %d, got %d.\n",
140 wcslen(checkstr1), wcslen(checkstr2), ret);
141 }
142}
143
144void DoArgumentPrecTest(const WCHAR *formatstr, int precision, void *param,
145 WCHAR *paramstr, const WCHAR *checkstr1, const WCHAR *checkstr2)
146{
147 int ret;
148
149 ret = wprintf(formatstr, precision, param);
150 if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2))
151 {
152 Fail("DoArgumentPrecTest:Expected wprintf to return %d or %d, got %d.\n",
153 wcslen(checkstr1), wcslen(checkstr2), ret);
154 }
155}
156
157void DoArgumentPrecDoubleTest(const WCHAR *formatstr, int precision, double param,
158 const WCHAR *checkstr1, const WCHAR *checkstr2)
159{
160 int ret;
161
162 ret = wprintf(formatstr, precision, param);
163 if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2))
164 {
165 Fail("DoArgumentPrecDoubleTest:Expected wprintf to return %d or %d, got %d.\n",
166 wcslen(checkstr1), wcslen(checkstr2), ret);
167 }
168}
169
170#endif
171
172