File: tstring9.pp

package info (click to toggle)
fpc 3.2.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, bullseye-backports
  • size: 338,552 kB
  • sloc: pascal: 3,794,737; xml: 191,997; ansic: 9,637; asm: 8,482; java: 5,346; sh: 4,664; yacc: 3,751; makefile: 2,688; lex: 2,538; javascript: 2,375; sql: 929; php: 473; cpp: 145; perl: 134; sed: 132; csh: 34; tcl: 7
file content (56 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
program tst2;
{$ifdef fpc}{$mode objfpc}{$h+}{$endif}

var
 a: array[0..0] of char = (#0);

function test_pchar: boolean;
var
 s: string;
 p: pchar;
begin
 p := '';
 s := '1234567890';
 s := p;
 test_pchar := (s = '');
 if not test_pchar then writeln('test_pchar failed');
end;

function test_chararray: boolean;
var
 s: string;
begin
 s := '1234567890';
 s := a;
 test_chararray := (s = '');
 if not test_chararray then writeln('test_chararray failed');  
end;

function test_pchar_to_widestr: boolean;
var
 s: widestring;
 p: PChar;
begin
 p := '';
 s := '1234567890';
 s := p;                         { win32: function result assign not optimized! }
 test_pchar_to_widestr := (s = '');
 if not test_pchar_to_widestr then writeln('test_pchar_to_widestr failed');  
end;

function test_chararray_to_widestr: boolean;
var
 s: widestring;
begin
 s := '1234567890';
 s := a;
 test_chararray_to_widestr := (s = '');
 if not test_chararray_to_widestr then writeln('test_chararray_to_widestr failed');  
end;

begin
 if not test_pchar then Halt(1);
 if not test_chararray then Halt(2);
 if not test_pchar_to_widestr then Halt(3);
 if not test_chararray_to_widestr then Halt(4);
end.