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

/test/lib/storage/collection/test_array_resize.e

http://github.com/tybor/Liberty
Specman e | 83 lines | 55 code | 7 blank | 21 comment | 0 complexity | 4fcd4270cc14647b2deff8f911e3f55f 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_ARRAY_RESIZE
 5
 6insert
 7   EIFFELTEST_TOOLS
 8
 9create {}
10   make
11
12feature {ANY}
13   ti1, ti2: ARRAY[INTEGER]
14
15   tc1, tc2: ARRAY[CAT]
16
17   c1, c2, c3, c4, c5, c6: CAT
18
19   make
20      do
21         ti1 := {ARRAY[INTEGER] 1, << 1, 2, 3, 4, 5, 6, 7, 8, 9 >> }
22         ti2 := {ARRAY[INTEGER] 1, << 1, 2, 3, 4, 5, 6, 7, 8, 9 >> }
23         ti1.resize(2, 9)
24         assert(ti1.is_equal(ti2.subarray(2, 9)))
25         ti1.resize(2, 8)
26         assert(ti1.is_equal(ti2.subarray(2, 8)))
27         ti1.resize(3, 7)
28         assert(ti1.is_equal(ti2.subarray(3, 7)))
29         ti1.resize(1, 9)
30         assert(ti1.is_equal({ARRAY[INTEGER] 1, << 0, 0, 3, 4, 5, 6, 7, 0, 0 >> }))
31         ti1.resize(1, 10)
32         assert(ti1.is_equal({ARRAY[INTEGER] 1, << 0, 0, 3, 4, 5, 6, 7, 0, 0, 0 >> }))
33         ti1.make(1, 9)
34         assert(ti1.is_equal({ARRAY[INTEGER] 1, << 0, 0, 0, 0, 0, 0, 0, 0, 0 >> }))
35         create c1
36         create c2
37         create c3
38         create c4
39         create c5
40         create c6
41         tc1 := {ARRAY[CAT] 1, << c1, c2, c3, c4, c5, c6 >> }
42         tc2 := {ARRAY[CAT] 2, << c2, c3, c4, c5, c6 >> }
43         tc1.resize(2, 6)
44         assert(tc1.is_equal(tc2))
45         tc2 := {ARRAY[CAT] 1, << c1, c2, c3, c4, c5, c6 >> }
46         assert(tc1.is_equal(tc2.subarray(2, 6)))
47         tc1.resize(2, 5)
48         assert(tc1.is_equal(tc2.subarray(2, 5)))
49         tc1.resize(3, 4)
50         assert(tc1.is_equal(tc2.subarray(3, 4)))
51         tc1.resize(1, 6)
52         assert(tc1.is_equal({ARRAY[CAT] 1, << Void, Void, c3, c4, Void, Void >> }))
53         tc1.resize(1, 7)
54         assert(tc1.is_equal({ARRAY[CAT] 1, << Void, Void, c3, c4, Void, Void, Void >> }))
55         tc1.make(1, 6)
56         tc2.clear_all
57         assert(tc1.is_equal(tc2))
58         tc1 := {ARRAY[CAT] 1, << c1, c2, c3, c4, c5, c6 >> }
59         tc2 := tc1.subarray(1, 0)
60         assert(tc2.is_empty)
61         tc2 := tc1.subarray(3, 2)
62         assert(tc2.is_empty)
63      end
64
65end -- class TEST_ARRAY_RESIZE
66--
67-- ------------------------------------------------------------------------------------------------------------------------------
68-- Copyright notice below. Please read.
69--
70-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
71-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
72-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
73-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
74-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
75-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
76--
77-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
78-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
79--
80-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
81--
82-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
83-- ------------------------------------------------------------------------------------------------------------------------------