PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/test/lib/numeric/mutable_big_integer/test_mutable_big_integer10.e

http://github.com/tybor/Liberty
Specman e | 98 lines | 67 code | 6 blank | 25 comment | 1 complexity | c6800915f7fe39bfbd73b72e124d6514 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_INTEGER10
 5   --
 6   -- Testing feature `add_integer'.
 7   --
 8
 9insert
10   ANY
11   PLATFORM
12
13create {}
14   make
15
16feature {ANY}
17   make
18      local
19         mbia: MUTABLE_BIG_INTEGER; ib: INTEGER
20      do
21         create mbia.from_integer(2)
22         ib := 0
23         mbia.add_integer(ib)
24         assert(mbia.to_integer_32 = 2)
25         assert(("2").is_equal(mbia.to_string))
26         mbia.from_integer(0)
27         ib := 2
28         mbia.add_integer(ib)
29         assert(mbia.to_integer_32 = 2)
30         assert(("2").is_equal(mbia.to_string))
31         mbia.from_integer(3)
32         ib := 2
33         mbia.add_integer(ib)
34         assert(mbia.to_integer_32 = 5)
35         assert(("5").is_equal(mbia.to_string))
36         mbia.from_integer_64(Maximum_integer_64)
37         ib := 2
38         mbia.add_integer(ib)
39         mbia.subtract_integer(ib)
40         assert(mbia.to_integer_64 = Maximum_integer_64)
41         mbia.add(mbia)
42         ib := 4096
43         mbia.add_integer(ib)
44         mbia.from_integer(3)
45         ib := -2
46         mbia.add_integer(ib)
47         assert(mbia.to_integer_32 = 1)
48         --|mbia| < |ib|
49         mbia.from_integer(2)
50         ib := -3
51         mbia.add_integer(ib)
52         assert(mbia.to_integer_32 = -1)
53         mbia.from_integer(-3)
54         ib := -2
55         mbia.add_integer(ib)
56         assert(mbia.to_integer_32 = -5)
57         mbia.from_integer(-3)
58         ib := 2
59         mbia.add_integer(ib)
60         assert(mbia.to_integer_32 = -1)
61         mbia.from_integer(-2)
62         ib := 3
63         mbia.add_integer(ib)
64         assert(mbia.to_integer_32 = 1)
65      end
66
67   count: INTEGER
68
69   assert (b: BOOLEAN)
70      do
71         count := count + 1
72         if not b then
73            sedb_breakpoint
74            io.put_string("TEST_MUTABLE_BIG_INTEGER10 : ERROR Test # ")
75            io.put_integer(count)
76            io.put_string("%N")
77         end
78      end
79
80end -- class TEST_MUTABLE_BIG_INTEGER10
81--
82-- ------------------------------------------------------------------------------------------------------------------------------
83-- Copyright notice below. Please read.
84--
85-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
86-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
87-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
88-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
89-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
90-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
91--
92-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
93-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
94--
95-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
96--
97-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
98-- ------------------------------------------------------------------------------------------------------------------------------