~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/tests/test/units/system/trdtxt03.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Program trdtxt03;
 
2
 
 
3
{$ifdef fpc}
 
4
uses
 
5
  strings;
 
6
{$else}
 
7
uses
 
8
  SysUtils;
 
9
{$endif}
 
10
 
 
11
procedure test(b: boolean);
 
12
begin
 
13
  if b then exit;
 
14
  WriteLn('Error : Invalid data read!');
 
15
  halt(1);
 
16
end;
 
17
 
 
18
var
 
19
 T: Text;
 
20
 value_char: char;
 
21
 value_byte: byte;
 
22
 value_shortint : shortint;
 
23
 value_smallint : smallint;
 
24
 value_word : word;
 
25
 value_longint : longint;
 
26
 value_longword : cardinal;
 
27
 value_real : real;
 
28
 value_shortstr : shortstring;
 
29
 value_pchar : array[0..255] of char;
 
30
Begin
 
31
 Assign(T,'testmac.txt');
 
32
 Reset(T);
 
33
 { Read all the data in the correct order }
 
34
 { Read some characters }
 
35
 value_char := #0;
 
36
 ReadLn(T,value_char);
 
37
 test(value_char = 'a');
 
38
 value_char := #0;
 
39
 ReadLn(T,value_char);
 
40
 test(value_char = 'c');
 
41
 value_char := #0;
 
42
 ReadLn(T,value_char);
 
43
 test(value_char = 'z');
 
44
 value_char := #0;
 
45
 ReadLn(T,value_char);
 
46
 test(value_char = '#');
 
47
 { ***** Read some integer values ***** }
 
48
 {**** HEX ****}
 
49
 value_byte := 0;
 
50
 ReadLn(T,value_byte);
 
51
 test(value_byte = 127);
 
52
 value_byte := 0;
 
53
 ReadLn(T,value_byte);
 
54
 test(value_byte = 255);
 
55
 value_byte := 0;
 
56
 ReadLn(T,value_byte);
 
57
 test(value_byte = 51);
 
58
 value_shortint := 0;
 
59
 ReadLn(T,value_shortint);
 
60
 test(value_shortint = -127);
 
61
 {*** Integral *** }
 
62
 value_byte := 0;
 
63
 ReadLn(T,value_byte);
 
64
 test(value_byte = 127);
 
65
 value_byte := 0;
 
66
 ReadLn(T,value_byte);
 
67
 test(value_byte = 255);
 
68
 value_byte := 0;
 
69
 ReadLn(T,value_byte);
 
70
 test(value_byte = 33);
 
71
 value_shortint := 0;
 
72
 ReadLn(T,value_shortint);
 
73
 test(value_shortint = -127);
 
74
 {**** HEX ****}
 
75
 value_word := 0;
 
76
 ReadLn(T,value_word);
 
77
 test(value_word = 32767);
 
78
 value_word := 0;
 
79
 ReadLn(T,value_word);
 
80
 test(value_word = 65535);
 
81
 value_word := 0;
 
82
 ReadLn(T,value_word);
 
83
 test(value_word = 4660);
 
84
 value_smallint := 0;
 
85
 ReadLn(T,value_smallint);
 
86
 test(value_smallint = -32767);
 
87
 {*** Integral *** }
 
88
 value_word := 0;
 
89
 ReadLn(T,value_word);
 
90
 test(value_word = 12700);
 
91
 value_word := 0;
 
92
 ReadLn(T,value_word);
 
93
 test(value_word = 2550);
 
94
 value_word := 0;
 
95
 ReadLn(T,value_word);
 
96
 test(value_word = +33200);
 
97
 value_smallint := 0;
 
98
 ReadLn(T,value_smallint);
 
99
 test(value_smallint = -12700);
 
100
 {**** HEX ****}
 
101
 value_longword := 0;
 
102
 ReadLn(T,value_longword);
 
103
 test(value_longword = +$7FFFFFFF);
 
104
 value_longword := 0;
 
105
 ReadLn(T,value_longword);
 
106
 test(value_longword = $FFFFFFFF);
 
107
 value_longword := 0;
 
108
 ReadLn(T,value_longword);
 
109
 test(value_longword = $12341234);
 
110
 value_longint := 0;
 
111
 ReadLn(T,value_longint);
 
112
 test(value_longint = -$7FFFFFFF);
 
113
 {*** Integral *** }
 
114
 value_longword := 0;
 
115
 ReadLn(T,value_longword);
 
116
 test(value_longword = 12700);
 
117
 value_longword := 0;
 
118
 ReadLn(T,value_longword);
 
119
 test(value_longword = 2550);
 
120
 value_longword := 0;
 
121
 ReadLn(T,value_longword);
 
122
 test(value_longword = +2147483647);
 
123
 value_longint := 0;
 
124
 ReadLn(T,value_longint);
 
125
{ test(value_longint = -2147483648);}
 
126
 
 
127
 { Read some real type values }
 
128
 value_real := 0.0;
 
129
 ReadLn(T,value_real);
 
130
 test(trunc(value_real) = trunc(01234));
 
131
 value_real := 0.0;
 
132
 ReadLn(T,value_real);
 
133
 test(trunc(value_real) = trunc(1278.1278));
 
134
 value_real := 0.0;
 
135
 ReadLn(T,value_real);
 
136
 test(trunc(value_real) = trunc(121223.1278E00));
 
137
 value_real := 0.0;
 
138
 ReadLn(T,value_real);
 
139
 test(trunc(value_real) = trunc(121224.1278e2));
 
140
 value_real := 0.0;
 
141
 ReadLn(T,value_real);
 
142
 test(trunc(value_real) = trunc(121225.1278E02));
 
143
 value_real := 0.0;
 
144
 ReadLn(T,value_real);
 
145
 test(trunc(value_real) = trunc(121216.1278E+00));
 
146
 value_real := 0.0;
 
147
 ReadLn(T,value_real);
 
148
 test(trunc(value_real) = trunc(121227.1278e+2));
 
149
 value_real := 0.0;
 
150
 ReadLn(T,value_real);
 
151
 test(trunc(value_real) = trunc(121228.1278E+02));
 
152
 value_real := 0.0;
 
153
 ReadLn(T,value_real);
 
154
 test(trunc(value_real) = trunc(121233.1278E-00));
 
155
 value_real := 0.0;
 
156
 ReadLn(T,value_real);
 
157
 test(trunc(value_real) = trunc(121234.1278e-2));
 
158
 
 
159
 { Read some strings }
 
160
 value_shortstr := '';
 
161
 ReadLn(T,value_shortstr);
 
162
 test(length(value_shortstr) = 255);
 
163
 value_shortstr := '';
 
164
 ReadLn(T,value_shortstr);
 
165
 test(value_shortstr = 'Hello world!');
 
166
 value_shortstr := '';
 
167
 ReadLn(T,value_shortstr);
 
168
 test(length(value_shortstr) = 42);
 
169
 { Read a null terminated value }
 
170
 value_shortstr := '';
 
171
 ReadLn(T,value_pchar);
 
172
 test(strlen(value_pchar) = 33);
 
173
 
 
174
 { Read a value_charhar and make sure the value is value_chartrl-Z (#26) }
 
175
 ReadLn(T,value_char);
 
176
 test(value_char = #26);
 
177
 Close(T);
 
178
 WriteLn('All tests Ok!');
 
179
end.