summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/test/units/sysutils/tstrtobool.pp
blob: a64f55f5cd8728a48c6a7e29d9a1b2289720e759 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
uses
  sysutils;
var
  b : boolean;
begin
  if not TryStrToBool('true',b) then
    halt(1);
  if not b then
    halt(1);
  if not TryStrToBool('false',b) then
    halt(1);
  if b then
    halt(1);

  if not TryStrToBool('True',b) then
    halt(1);
  if not b then
    halt(1);
  if not TryStrToBool('False',b) then
    halt(1);
  if b then
    halt(1);

  if not TryStrToBool('truE',b) then
    halt(1);
  if not b then
    halt(1);
  if not TryStrToBool('falsE',b) then
    halt(1);
  if b then
    halt(1);

  if not TryStrToBool('TRUE',b) then
    halt(1);
  if not b then
    halt(1);
  if not TryStrToBool('FALSE',b) then
    halt(1);
  if b then
    halt(1);

  if not TryStrToBool('3.1415',b) then
    halt(1);
  if not b then
    halt(1);
  if not TryStrToBool('0.0',b) then
    halt(1);
  if b then
    halt(1);

  if TryStrToBool('',b) then
    halt(1);

  if TryStrToBool('asdf',b) then
    halt(1);

  b:=StrToBool('truE');
  if not b then
    halt(1);
  b:=StrToBool('falsE');
  if b then
    halt(1);

  if not(StrToBoolDef('',true)) then
    halt(1);

  if StrToBoolDef('asdf',false) then
    halt(1);

  writeln('ok');
end.