~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gdiplus/tests/stringformat.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit test suite for string format
  3  *
  4  * Copyright (C) 2007 Google (Evan Stade)
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "windows.h"
 22 #include "gdiplus.h"
 23 #include "wine/test.h"
 24 
 25 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 26 #define expectf(expected, got) ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
 27 
 28 static void test_constructor(void)
 29 {
 30     GpStringFormat *format;
 31     GpStatus stat;
 32     INT n;
 33     StringAlignment align, valign;
 34     StringTrimming trimming;
 35     StringDigitSubstitute digitsub;
 36     LANGID digitlang;
 37 
 38     stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
 39     expect(Ok, stat);
 40 
 41     GdipGetStringFormatAlign(format, &align);
 42     GdipGetStringFormatLineAlign(format, &valign);
 43     GdipGetStringFormatHotkeyPrefix(format, &n);
 44     GdipGetStringFormatTrimming(format, &trimming);
 45     GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
 46 
 47     expect(HotkeyPrefixNone, n);
 48     expect(StringAlignmentNear, align);
 49     expect(StringAlignmentNear, align);
 50     expect(StringTrimmingCharacter, trimming);
 51     expect(StringDigitSubstituteUser, digitsub);
 52     expect(LANG_NEUTRAL, digitlang);
 53 
 54     stat = GdipDeleteStringFormat(format);
 55     expect(Ok, stat);
 56 }
 57 
 58 static void test_characterrange(void)
 59 {
 60     CharacterRange ranges[3];
 61     INT count;
 62     GpStringFormat* format;
 63     GpStatus stat;
 64 
 65     stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
 66     expect(Ok, stat);
 67 todo_wine
 68 {
 69     stat = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges);
 70     expect(Ok, stat);
 71     stat = GdipGetStringFormatMeasurableCharacterRangeCount(format, &count);
 72     expect(Ok, stat);
 73     if (stat == Ok) expect(3, count);
 74 }
 75     stat= GdipDeleteStringFormat(format);
 76     expect(Ok, stat);
 77 }
 78 
 79 static void test_digitsubstitution(void)
 80 {
 81     GpStringFormat *format;
 82     GpStatus stat;
 83     StringDigitSubstitute digitsub;
 84     LANGID digitlang;
 85 
 86     stat = GdipCreateStringFormat(0, LANG_RUSSIAN, &format);
 87     expect(Ok, stat);
 88 
 89     /* NULL arguments */
 90     stat = GdipGetStringFormatDigitSubstitution(NULL, NULL, NULL);
 91     expect(InvalidParameter, stat);
 92     stat = GdipGetStringFormatDigitSubstitution(format, NULL, NULL);
 93     expect(Ok, stat);
 94     stat = GdipGetStringFormatDigitSubstitution(NULL, &digitlang, NULL);
 95     expect(InvalidParameter, stat);
 96     stat = GdipGetStringFormatDigitSubstitution(NULL, NULL, &digitsub);
 97     expect(InvalidParameter, stat);
 98     stat = GdipGetStringFormatDigitSubstitution(NULL, &digitlang, &digitsub);
 99     expect(InvalidParameter, stat);
100     stat = GdipSetStringFormatDigitSubstitution(NULL, LANG_NEUTRAL, StringDigitSubstituteNone);
101     expect(InvalidParameter, stat);
102 
103     /* try to get both and one by one */
104     stat = GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
105     expect(Ok, stat);
106     expect(StringDigitSubstituteUser, digitsub);
107     expect(LANG_NEUTRAL, digitlang);
108 
109     digitsub  = StringDigitSubstituteNone;
110     stat = GdipGetStringFormatDigitSubstitution(format, NULL, &digitsub);
111     expect(Ok, stat);
112     expect(StringDigitSubstituteUser, digitsub);
113 
114     digitlang = LANG_RUSSIAN;
115     stat = GdipGetStringFormatDigitSubstitution(format, &digitlang, NULL);
116     expect(Ok, stat);
117     expect(LANG_NEUTRAL, digitlang);
118 
119     /* set/get */
120     stat = GdipSetStringFormatDigitSubstitution(format, MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL),
121                                                         StringDigitSubstituteUser);
122     expect(Ok, stat);
123     digitsub  = StringDigitSubstituteNone;
124     digitlang = LANG_RUSSIAN;
125     stat = GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
126     expect(Ok, stat);
127     expect(StringDigitSubstituteUser, digitsub);
128     expect(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL), digitlang);
129 
130     stat = GdipDeleteStringFormat(format);
131     expect(Ok, stat);
132 }
133 
134 static void test_getgenerictypographic(void)
135 {
136     GpStringFormat *format;
137     GpStatus stat;
138     INT flags;
139     INT n;
140     StringAlignment align, valign;
141     StringTrimming trimming;
142     StringDigitSubstitute digitsub;
143     LANGID digitlang;
144     INT tabcount;
145 
146     /* NULL arg */
147     stat = GdipStringFormatGetGenericTypographic(NULL);
148     expect(InvalidParameter, stat);
149 
150     stat = GdipStringFormatGetGenericTypographic(&format);
151     expect(Ok, stat);
152 
153     GdipGetStringFormatFlags(format, &flags);
154     GdipGetStringFormatAlign(format, &align);
155     GdipGetStringFormatLineAlign(format, &valign);
156     GdipGetStringFormatHotkeyPrefix(format, &n);
157     GdipGetStringFormatTrimming(format, &trimming);
158     GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
159     GdipGetStringFormatTabStopCount(format, &tabcount);
160 
161     expect((StringFormatFlagsNoFitBlackBox |StringFormatFlagsLineLimit | StringFormatFlagsNoClip),
162             flags);
163     expect(HotkeyPrefixNone, n);
164     expect(StringAlignmentNear, align);
165     expect(StringAlignmentNear, align);
166     expect(StringTrimmingNone, trimming);
167     expect(StringDigitSubstituteUser, digitsub);
168     expect(LANG_NEUTRAL, digitlang);
169     expect(0, tabcount);
170 
171     stat = GdipDeleteStringFormat(format);
172     expect(Ok, stat);
173 }
174 
175 static REAL tabstops[] = {0.0, 10.0, 2.0};
176 static void test_tabstops(void)
177 {
178     GpStringFormat *format;
179     GpStatus stat;
180     INT count;
181     REAL tabs[3];
182     REAL firsttab;
183 
184     stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
185     expect(Ok, stat);
186 
187     /* NULL */
188     stat = GdipGetStringFormatTabStopCount(NULL, NULL);
189     expect(InvalidParameter, stat);
190     stat = GdipGetStringFormatTabStopCount(NULL, &count);
191     expect(InvalidParameter, stat);
192     stat = GdipGetStringFormatTabStopCount(format, NULL);
193     expect(InvalidParameter, stat);
194 
195     stat = GdipSetStringFormatTabStops(NULL, 0.0, 0, NULL);
196     expect(InvalidParameter, stat);
197     stat = GdipSetStringFormatTabStops(format, 0.0, 0, NULL);
198     expect(InvalidParameter, stat);
199     stat = GdipSetStringFormatTabStops(NULL, 0.0, 0, tabstops);
200     expect(InvalidParameter, stat);
201 
202     stat = GdipGetStringFormatTabStops(NULL, 0, NULL, NULL);
203     expect(InvalidParameter, stat);
204     stat = GdipGetStringFormatTabStops(format, 0, NULL, NULL);
205     expect(InvalidParameter, stat);
206     stat = GdipGetStringFormatTabStops(NULL, 0, &firsttab, NULL);
207     expect(InvalidParameter, stat);
208     stat = GdipGetStringFormatTabStops(NULL, 0, NULL, tabs);
209     expect(InvalidParameter, stat);
210     stat = GdipGetStringFormatTabStops(format, 0, &firsttab, NULL);
211     expect(InvalidParameter, stat);
212     stat = GdipGetStringFormatTabStops(format, 0, NULL, tabs);
213     expect(InvalidParameter, stat);
214 
215     /* not NULL */
216     stat = GdipGetStringFormatTabStopCount(format, &count);
217     expect(Ok, stat);
218     expect(0, count);
219     /* negative tabcount */
220     stat = GdipSetStringFormatTabStops(format, 0.0, -1, tabstops);
221     expect(Ok, stat);
222     count = -1;
223     stat = GdipGetStringFormatTabStopCount(format, &count);
224     expect(Ok, stat);
225     expect(0, count);
226 
227     stat = GdipSetStringFormatTabStops(format, -10.0, 0, tabstops);
228     expect(Ok, stat);
229     stat = GdipSetStringFormatTabStops(format, -10.0, 1, tabstops);
230     expect(NotImplemented, stat);
231 
232     firsttab = -1.0;
233     tabs[0] = tabs[1] = tabs[2] = -1.0;
234     stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs);
235     expect(Ok, stat);
236     expectf(-1.0, tabs[0]);
237     expectf(-1.0, tabs[1]);
238     expectf(-1.0, tabs[2]);
239     expectf(0.0, firsttab);
240 
241     stat = GdipSetStringFormatTabStops(format, +0.0, 3, tabstops);
242     expect(Ok, stat);
243     count = 0;
244     stat = GdipGetStringFormatTabStopCount(format, &count);
245     expect(Ok, stat);
246     expect(3, count);
247 
248     firsttab = -1.0;
249     tabs[0] = tabs[1] = tabs[2] = -1.0;
250     stat = GdipGetStringFormatTabStops(format, 3, &firsttab, tabs);
251     expect(Ok, stat);
252     expectf(0.0,  tabs[0]);
253     expectf(10.0, tabs[1]);
254     expectf(2.0,  tabs[2]);
255     expectf(0.0,  firsttab);
256 
257     stat = GdipSetStringFormatTabStops(format, 10.0, 3, tabstops);
258     expect(Ok, stat);
259     firsttab = -1.0;
260     tabs[0] = tabs[1] = tabs[2] = -1.0;
261     stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs);
262     expect(Ok, stat);
263     expectf(-1.0, tabs[0]);
264     expectf(-1.0, tabs[1]);
265     expectf(-1.0, tabs[2]);
266     expectf(10.0, firsttab);
267 
268     /* zero tabcount, after valid setting to 3 */
269     stat = GdipSetStringFormatTabStops(format, 0.0, 0, tabstops);
270     expect(Ok, stat);
271     count = 0;
272     stat = GdipGetStringFormatTabStopCount(format, &count);
273     expect(Ok, stat);
274     expect(3, count);
275 
276     stat = GdipDeleteStringFormat(format);
277     expect(Ok, stat);
278 }
279 
280 static void test_getgenericdefault(void)
281 {
282     GpStringFormat *format;
283     GpStatus stat;
284 
285     INT flags;
286     INT n;
287     StringAlignment align, valign;
288     StringTrimming trimming;
289     StringDigitSubstitute digitsub;
290     LANGID digitlang;
291     INT tabcount;
292 
293     /* NULL arg */
294     stat = GdipStringFormatGetGenericDefault(NULL);
295     expect(InvalidParameter, stat);
296 
297     stat = GdipStringFormatGetGenericDefault(&format);
298     expect(Ok, stat);
299 
300     GdipGetStringFormatFlags(format, &flags);
301     GdipGetStringFormatAlign(format, &align);
302     GdipGetStringFormatLineAlign(format, &valign);
303     GdipGetStringFormatHotkeyPrefix(format, &n);
304     GdipGetStringFormatTrimming(format, &trimming);
305     GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
306     GdipGetStringFormatTabStopCount(format, &tabcount);
307 
308     expect(0, flags);
309     expect(HotkeyPrefixNone, n);
310     expect(StringAlignmentNear, align);
311     expect(StringAlignmentNear, align);
312     expect(StringTrimmingCharacter, trimming);
313     expect(StringDigitSubstituteUser, digitsub);
314     expect(LANG_NEUTRAL, digitlang);
315     expect(0, tabcount);
316 
317     stat = GdipDeleteStringFormat(format);
318     expect(Ok, stat);
319 }
320 
321 START_TEST(stringformat)
322 {
323     struct GdiplusStartupInput gdiplusStartupInput;
324     ULONG_PTR gdiplusToken;
325 
326     gdiplusStartupInput.GdiplusVersion              = 1;
327     gdiplusStartupInput.DebugEventCallback          = NULL;
328     gdiplusStartupInput.SuppressBackgroundThread    = 0;
329     gdiplusStartupInput.SuppressExternalCodecs      = 0;
330 
331     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
332 
333     test_constructor();
334     test_characterrange();
335     test_digitsubstitution();
336     test_getgenerictypographic();
337     test_tabstops();
338     test_getgenericdefault();
339 
340     GdiplusShutdown(gdiplusToken);
341 }
342 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.