PageRenderTime 28ms CodeModel.GetById 22ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/test/lib/storage/collection/test_slice1.e

http://github.com/tybor/Liberty
Specman e | 88 lines | 61 code | 6 blank | 21 comment | 0 complexity | 2105b433fd2ea9d1f4ff6216a4ea720b 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_SLICE1
 5
 6insert
 7   EIFFELTEST_TOOLS
 8   
 9create {}
10   make
11
12feature {ANY}
13   make
14      local
15         model2: FAST_ARRAY[INTEGER]; model3: ARRAY[INTEGER]
16      do
17         test({ARRAY[INTEGER] 1, << 1, 2, 3, 4 >> })
18         create model2.from_collection({ARRAY[INTEGER] 1, << 1, 2, 3, 4 >> })
19         test(model2)
20         create model3.make(-2, 1)
21         model3.put(1, -2)
22         model3.put(2, -1)
23         model3.put(3, 0)
24         model3.put(4, 1)
25         test(model3)
26      end
27
28   test (model: COLLECTION[INTEGER])
29      local
30         a: ARRAY[INTEGER]; fa: FAST_ARRAY[INTEGER]; ll: LINKED_LIST[INTEGER]; l2l: TWO_WAY_LINKED_LIST[INTEGER]
31      do
32         create a.from_collection(model)
33         test1(a)
34         create fa.from_collection(model)
35         test1(fa)
36         create ll.from_collection(model)
37         test1(ll)
38         create l2l.from_collection(model)
39         test1(l2l)
40      end
41
42feature {}
43   test1 (model: COLLECTION[INTEGER])
44      local
45         slice: like model
46      do
47         slice := model.slice(model.lower, model.lower)
48         assert(slice.last = 1)
49         slice := model.slice(model.lower, model.lower + 1)
50         assert(slice.first = 1)
51         assert(slice.last = 2)
52         slice := model.slice(model.lower + 1, model.lower + 1)
53         assert(slice.first = 2)
54         slice := model.slice(model.lower + 1, model.lower + 2)
55         assert(slice.first = 2)
56         assert(slice.last = 3)
57         slice := model.slice(model.upper, model.upper)
58         assert(slice.last = 4)
59         slice := model.slice(model.upper - 1, model.upper)
60         assert(slice.first = 3)
61         assert(slice.last = 4)
62         slice := model.slice(model.lower, model.upper)
63         assert(slice.is_equal(model))
64         slice := model.slice(model.lower, model.lower - 1)
65         assert(slice.is_empty)
66         slice := model.slice(model.upper, model.upper - 1)
67         assert(slice.is_empty)
68      end
69
70end -- class TEST_SLICE1
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-- ------------------------------------------------------------------------------------------------------------------------------