PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/collection/test_index_of1.e

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