1
{****************************************************************}
2
{ CODE GENERATOR TEST PROGRAM }
3
{ Copyright (c) 2002, Carl Eric Codere }
4
{****************************************************************}
5
{ NODE TESTED : secondtypeconvert() -> second_string_string }
6
{****************************************************************}
7
{ PRE-REQUISITES: secondload() }
10
{****************************************************************}
12
{ FPC = Target is FreePascal compiler }
13
{****************************************************************}
14
{ REMARKS: Same type short conversion is not tested, except for }
15
{ shortstrings , since it requires special handling. }
18
{****************************************************************}
23
{$define haswidestring}
27
{$define haswidestring}
34
{ exactly 255 characters in length }
36
' This is a small text documentation to verify the validity of'+
37
' the string conversion routines. Of course the conversion routines'+
38
' should normally work like a charm, and this can only test that there'+
39
' aren''t any problems with maximum length strings. This fix!';
40
{ < 255 characters in length }
41
SMALL_STRING = 'This is a small hello!';
42
{ > 255 characters in length }
43
HUGE_STRING_END = ' the goal of this experiment';
45
' This is a huge text documentation to verify the validity of'+
46
' the string conversion routines. Of course the conversion routines'+
47
' should normally work like a charm, and this can only test that there'+
48
' aren''t any problems with maximum length strings. I hope you understand'+
53
shortstr = string[127];
57
str_short: shortstring;
58
{$ifdef haswidestring}
59
str_wide : widestring;
70
procedure test_ansi_to_short;
72
{************************************************************************}
73
{ ansistring -> shortstring }
74
{************************************************************************}
75
WriteLn('Test ansistring -> shortstring');
76
{ ansistring -> shortstring }
79
str_ansi := SMALL_STRING;
81
Write('small ansistring -> shortstring...');
82
if str_short = str_ansi then
89
str_ansi := EMPTY_STRING;
91
Write('empty ansistring -> shortstring...');
92
if str_short = str_ansi then
100
str_ansi := BIG_STRING;
102
Write('big ansistring -> shortstring...');
103
if str_short = str_ansi then
109
Write('huge ansistring -> shortstring...');
112
str_ansi := HUGE_STRING;
114
{ Delphi 3/Delphi 6 does not consider these as the same string }
115
if str_short <> str_ansi then
122
str_ansi := SMALL_STRING;
124
Write('small ansistring -> shortstring...');
125
if s2 = str_ansi then
132
str_ansi := EMPTY_STRING;
134
Write('empty ansistring -> shortstring...');
135
if s2 = str_ansi then
142
str_ansi := BIG_STRING;
144
Write('big ansistring -> shortstring...');
145
{ Should fail, since comparing different string lengths }
146
if s2 <> str_ansi then
153
str_ansi := HUGE_STRING;
155
Write('huge ansistring -> shortstring...');
156
{ Should fail, since comparing different string lengths }
157
if s2 <> str_ansi then
164
procedure test_short_to_short;
166
{************************************************************************}
167
{ shortstring -> shortstring }
168
{************************************************************************}
169
WriteLn('Test shortstring -> shortstring...');
170
{ shortstring -> shortstring }
175
Write('small shortstring -> shortstring...');
176
if str_short = s2 then
185
Write('empty shortstring -> shortstring...');
186
if str_short = s2 then
192
{ Delphi does not compile these }
197
Write('big shortstring -> shortstring...');
198
if str_short = s2 then
208
Write('huge shortstring -> shortstring...');
209
{ Delphi 3/Delphi 6 does not consider these as the same string }
210
if str_short = s2 then
218
str_short := SMALL_STRING;
219
Write('small shortstring -> shortstring...');
221
if s2 = str_short then
228
str_short := EMPTY_STRING;
229
Write('empty shortstring -> shortstring...');
231
if s2 = str_short then
238
str_short := BIG_STRING;
239
Write('big shortstring -> shortstring...');
241
{ Should fail, since comparing different string lengths }
242
if s2 <> str_short then
250
str_short := HUGE_STRING;
251
Write('huge shortstring -> shortstring...');
253
{ Should fail, since comparing different string lengths }
254
if s2 <> str_short then
262
procedure test_short_to_ansi;
264
{************************************************************************}
265
{ shortstring -> ansistring }
266
{************************************************************************}
267
WriteLn('Test shortstring -> ansistring');
268
Write('small shortstring -> ansistring...');
269
{ shortstring -> ansistring }
270
str_short := SMALL_STRING;
272
if str_short = str_ansi then
277
Write('empty shortstring -> ansistring...');
278
str_short := EMPTY_STRING;
280
if str_short = str_ansi then
285
Write('big shortstring -> ansistring...');
286
str_short := BIG_STRING;
288
if str_short = str_ansi then
293
Write('small shortstring -> ansistring...');
294
{ shortstring -> ansistring }
297
if s2 = str_ansi then
302
Write('empty shortstring -> ansistring...');
305
if s2 = str_ansi then
313
{$ifdef haswidestring}
314
procedure test_wide_to_ansi;
316
{************************************************************************}
317
{ widestring -> ansistring }
318
{************************************************************************}
319
WriteLn('Test widestring -> ansistring');
320
Write('small widestring -> ansistring...');
321
{ widestring -> ansistring }
322
str_wide := SMALL_STRING;
324
if str_wide = str_ansi then
329
Write('empty widestring -> ansistring...');
330
str_wide := EMPTY_STRING;
332
if str_wide = str_ansi then
337
Write('big widestring -> ansistring...');
338
str_wide := BIG_STRING;
340
if str_wide = str_ansi then
345
Write('huge widestring -> ansistring...');
346
str_wide := HUGE_STRING;
348
if str_wide = str_ansi then
357
procedure test_short_to_wide;
359
{************************************************************************}
360
{ shortstring -> widestring }
361
{************************************************************************}
362
WriteLn('Test shortstring -> widestring');
363
Write('small shortstring -> widestring...');
364
{ shortstring -> widestring }
365
str_short := SMALL_STRING;
367
if str_short = str_wide then
372
Write('empty shortstring -> widestring...');
373
str_short := EMPTY_STRING;
375
if str_short = str_wide then
380
Write('big shortstring -> widestring...');
381
str_short := BIG_STRING;
383
if str_short = str_wide then
388
Write('small shortstring -> widestring...');
389
{ shortstring -> widestring }
392
if s2 = str_wide then
397
Write('empty shortstring -> widestring...');
400
if s2 = str_wide then
408
procedure test_ansi_to_wide;
410
{************************************************************************}
411
{ ansistring -> widestring }
412
{************************************************************************}
413
WriteLn('Test ansistring -> widestring');
414
Write('small ansistring -> widestring...');
415
{ ansistring -> widestring }
416
str_ansi := SMALL_STRING;
418
if str_ansi = str_wide then
423
Write('empty ansistring -> widestring...');
424
str_ansi := EMPTY_STRING;
426
if str_ansi = str_wide then
431
Write('big ansistring -> widestring...');
432
str_ansi := BIG_STRING;
434
if str_ansi = str_wide then
439
Write('small ansistring -> widestring...');
440
{ ansistring -> widestring }
443
if s2 = str_wide then
448
Write('empty ansistring -> widestring...');
451
if s2 = str_wide then
460
procedure test_wide_to_short;
462
{************************************************************************}
463
{ widestring -> shortstring }
464
{************************************************************************}
465
WriteLn('Test widestring -> shortstring');
466
{ widestring -> shortstring }
469
str_wide := SMALL_STRING;
470
Write('small widestring -> shortstring...');
472
if str_short = str_wide then
479
str_wide := EMPTY_STRING;
480
Write('empty widestring -> shortstring...');
482
if str_short = str_wide then
488
Write('big widestring -> shortstring...');
491
str_wide := BIG_STRING;
493
if str_short = str_wide then
498
Write('huge widestring -> shortstring...');
499
str_wide := HUGE_STRING;
501
if str_short <> str_wide then
507
Write('small widestring -> shortstring...');
510
str_wide := SMALL_STRING;
512
if s2 = str_wide then
517
Write('empty widestring -> shortstring...');
520
str_wide := EMPTY_STRING;
522
if s2 = str_wide then
527
Write('big widestring -> shortstring...');
530
str_wide := BIG_STRING;
532
if s2 <> str_wide then
537
Write('huge widestring -> shortstring...');
540
str_wide := HUGE_STRING;
542
if s2 <> str_wide then
553
{ requires widestring support }
554
{$ifdef haswidestring}