PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/collection/test_remove1.e

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