1 (* Copyright (C) 2009 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
20 FROM FpuIO IMPORT WriteLongReal, LongRealToStr ;
21 FROM StrLib IMPORT StrEqual ;
22 FROM libc IMPORT exit, printf ;
23 FROM StrIO IMPORT WriteLn ;
24 FROM FIO IMPORT FlushBuffer, StdOut ;
26 PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ;
31 printf("%s:%d:regression test failed during execution\n",
39 s: ARRAY [0..20] OF CHAR ;
45 WriteLongReal(a, 5, 2) ; WriteLn ;
46 LongRealToStr(a, 5, 2, s) ;
47 Assert(StrEqual(s, '-0.01'), __LINE__) ;
50 WriteLongReal(a,15,11) ; WriteLn ;
51 LongRealToStr(a, 15, 11, s) ;
52 Assert(StrEqual(s, ' 0.10000000000'), __LINE__) ;
55 WriteLongReal(a, 5, 2) ; WriteLn ;
56 LongRealToStr(a, 5, 2, s) ;
57 Assert(StrEqual(s, ' 0.01'), __LINE__) ;
60 WriteLongReal(a, 11, 9) ; WriteLn ;
61 LongRealToStr(a, 11, 9, s) ;
62 Assert(StrEqual(s, '0.000000001'), __LINE__) ;
65 WriteLongReal(a, 10, 8) ; WriteLn ;
66 LongRealToStr(a, 10, 8, s) ;
67 Assert(StrEqual(s, '0.00000001'), __LINE__) ;
70 WriteLongReal(a,15,11) ; WriteLn ;
71 LongRealToStr(a, 15, 11, s) ;
72 Assert(StrEqual(s, ' 0.25000000000'), __LINE__) ;
75 WriteLongReal(a, 5, 2) ; WriteLn ;
76 LongRealToStr(a, 5, 2, s) ;
77 Assert(StrEqual(s, ' 0.12'), __LINE__) ;
80 WriteLongReal(a, 6, 3) ; WriteLn ;
81 LongRealToStr(a, 6, 3, s) ;
82 Assert(StrEqual(s, ' 0.001'), __LINE__) ;
85 WriteLongReal(a, 7, 4) ; WriteLn ;
86 LongRealToStr(a, 7, 4, s) ;
87 Assert(StrEqual(s, ' 0.0001'), __LINE__) ;
90 WriteLongReal(a, 8, 5) ; WriteLn ;
91 LongRealToStr(a, 8, 5, s) ;
92 Assert(StrEqual(s, ' 0.00001'), __LINE__) ;