summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw16004.pp
blob: bf16a89291da8921b270173cbc1e28f555c65932 (plain)
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
{$apptype console}
{$mode Delphi}
{$assertions on}
{$codepage cp1251}

function verify(const p; const size: integer; const z: array of byte): boolean;
begin
	assert( size = length(z)*sizeof(z[0]) );
	result := CompareByte(p, z[0], size) = 0;
	writeln(result)
end;

	procedure foo;
	var a: array[0..5] of char = 'willow';
	const b: array[0..2] of WideChar = 'èâà';
	begin
		assert( verify(a, sizeof(a), [ord('w'), ord('i'), ord('l'), ord('l'), ord('o'), ord('w')]) );
{$ifdef endian_big}
		assert( verify(b, sizeof(b), [$04,$38,$04,$32,$04,$30]) )
{$else}
		assert( verify(b, sizeof(b), [$38,$04,$32,$04,$30,$04]) )
{$endif}
	end;

const c: array[0..10] of char = 'rosenberg';
var d: array[0..10] of WideChar = 'ðîçåíáåðã';
	z: array[0..1] of WideChar = 'û';
	x: array[0..0] of char = 'x';
begin
	assert( verify(c, sizeof(c), [114, 111, 115, 101, 110, 98, 101, 114, 103, 0, 0]) );
{$ifdef endian_big}
	assert( verify(d, sizeof(d), [$04,$40,$04,$3E,$04,$37,$04,$35,$04,$3D,$04,$31,$04,$35,$04,$40,$04,$33,0,0,0,0]) );
{$else}
	assert( verify(d, sizeof(d), [$40,$04,$3E,$04,$37,$04,$35,$04,$3D,$04,$31,$04,$35,$04,$40,$04,$33,$04,0,0,0,0]) );
{$endif}
	foo;
{$ifdef endian_big}
	assert( verify(z, sizeof(z), [$04,$4B,0,0]) );
{$else}
	assert( verify(z, sizeof(z), [$4B,$04,0,0]) );
{$endif}
	assert( verify(x, sizeof(x), [120]) )
end.