PageRenderTime 26ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/numeric/mutable_big_integer/test_mutable_big_integer5.e

http://github.com/tybor/Liberty
Specman e | 182 lines | 146 code | 7 blank | 29 comment | 5 complexity | 279a539bf70e8d6367700aab5c0ecb0c MD5 | raw file
  1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2-- See the Copyright notice at the end of this file.
  3--
  4class TEST_MUTABLE_BIG_INTEGER5
  5   --
  6   -- Testing comparison.
  7   --
  8
  9insert
 10   ANY
 11   PLATFORM
 12
 13create {}
 14   make
 15
 16feature {ANY}
 17   make
 18      do
 19         check_compare(1, 2)
 20         --
 21         check_compare(0, 0)
 22         check_compare(1, 0)
 23         check_compare(1, 1)
 24         check_compare(2, 0)
 25         check_compare(2, 1)
 26         check_compare(3, 0)
 27         check_compare(3, 1)
 28         check_compare(3, 2)
 29         check_compare(3, 3)
 30         check_compare(Maximum_integer - 3, 0)
 31         check_compare(Maximum_integer - 3, 1)
 32         check_compare(Maximum_integer - 3, 2)
 33         check_compare(Maximum_integer - 3, 3)
 34         check_compare(Maximum_integer, 0)
 35         check_compare(Maximum_integer, 1)
 36         check_compare(Maximum_integer, 2)
 37         check_compare(Maximum_integer, 3)
 38         check_compare(Maximum_integer, Maximum_integer.to_integer_64)
 39         check_compare(Maximum_integer, Maximum_integer.to_integer_64 + 1)
 40         check_compare(Maximum_integer, Maximum_integer.to_integer_64 + 2)
 41         check_compare(Maximum_integer, Maximum_integer.to_integer_64 + 3)
 42         check_compare(Maximum_integer, Maximum_integer.to_integer_64 + 4)
 43         check_compare(Maximum_integer_64 - 3, 0)
 44         check_compare(Maximum_integer_64 - 3, 1)
 45         check_compare(Maximum_integer_64 - 3, 2)
 46         check_compare(Maximum_integer_64 - 3, 3)
 47         check_compare(Maximum_integer_64, 1)
 48         check_compare(Maximum_integer_64, Maximum_integer_64)
 49      end
 50
 51   count: INTEGER
 52
 53   assert (b: BOOLEAN)
 54      do
 55         count := count + 1
 56         if not b then
 57            sedb_breakpoint
 58            io.put_string("TEST_MUTABLE_BIG_INTEGER5 : ERROR Test # ")
 59            io.put_integer(count)
 60            io.put_string("%N")
 61         end
 62      end
 63
 64   check_compare (a, b: INTEGER_64)
 65      local
 66         c, d: INTEGER_64; mbia, mbib: MUTABLE_BIG_INTEGER
 67      do
 68         --
 69         create mbia.from_integer_64(a)
 70         create mbib.from_integer_64(b)
 71         if a < b then
 72            assert(mbia < mbib)
 73            assert(mbia <= mbib)
 74            assert(mbib > mbia)
 75            assert(mbib >= mbia)
 76            assert(not mbia.is_equal(mbib))
 77         elseif b < a then
 78            assert(mbib < mbia)
 79            assert(mbib <= mbia)
 80            assert(mbia > mbib)
 81            assert(mbia >= mbib)
 82            assert(not mbia.is_equal(mbib))
 83         else
 84            assert(not (mbib < mbia))
 85            assert(mbib >= mbia)
 86            assert(not (mbia > mbib))
 87            assert(mbia <= mbib)
 88            assert(mbia.is_equal(mbib))
 89         end
 90         --
 91         c := -a
 92         d := b
 93         create mbia.from_integer_64(c)
 94         create mbib.from_integer_64(d)
 95         if c < d then
 96            assert(mbia < mbib)
 97            assert(mbia <= mbib)
 98            assert(mbib > mbia)
 99            assert(mbib >= mbia)
100            assert(not mbia.is_equal(mbib))
101         elseif d < c then
102            assert(mbib < mbia)
103            assert(mbib <= mbia)
104            assert(mbia > mbib)
105            assert(mbia >= mbib)
106            assert(not mbia.is_equal(mbib))
107         else
108            assert(not (mbib < mbia))
109            assert(mbib >= mbia)
110            assert(not (mbia > mbib))
111            assert(mbia <= mbib)
112            assert(mbia.is_equal(mbib))
113         end
114         --
115         c := a
116         d := -b
117         create mbia.from_integer_64(c)
118         create mbib.from_integer_64(d)
119         if c < d then
120            assert(mbia < mbib)
121            assert(mbia <= mbib)
122            assert(mbib > mbia)
123            assert(mbib >= mbia)
124            assert(not mbia.is_equal(mbib))
125         elseif d < c then
126            assert(mbib < mbia)
127            assert(mbib <= mbia)
128            assert(mbia > mbib)
129            assert(mbia >= mbib)
130            assert(not mbia.is_equal(mbib))
131         else
132            assert(not (mbib < mbia))
133            assert(mbib >= mbia)
134            assert(not (mbia > mbib))
135            assert(mbia <= mbib)
136            assert(mbia.is_equal(mbib))
137         end
138         --
139         c := -a
140         d := -b
141         create mbia.from_integer_64(c)
142         create mbib.from_integer_64(d)
143         if c < d then
144            assert(mbia < mbib)
145            assert(mbia <= mbib)
146            assert(mbib > mbia)
147            assert(mbib >= mbia)
148            assert(not mbia.is_equal(mbib))
149         elseif d < c then
150            assert(mbib < mbia)
151            assert(mbib <= mbia)
152            assert(mbia > mbib)
153            assert(mbia >= mbib)
154            assert(not mbia.is_equal(mbib))
155         else
156            assert(not (mbib < mbia))
157            assert(mbib >= mbia)
158            assert(not (mbia > mbib))
159            assert(mbia <= mbib)
160            assert(mbia.is_equal(mbib))
161         end
162      end
163
164end -- class TEST_MUTABLE_BIG_INTEGER5
165--
166-- ------------------------------------------------------------------------------------------------------------------------------
167-- Copyright notice below. Please read.
168--
169-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
170-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
171-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
172-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
173-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
174-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
175--
176-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
177-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
178--
179-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
180--
181-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
182-- ------------------------------------------------------------------------------------------------------------------------------