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

/test/lib/storage/dictionary/test_dictionary2.e

http://github.com/tybor/Liberty
Specman e | 77 lines | 49 code | 7 blank | 21 comment | 0 complexity | e77253f547f0900b65610e7eb65a84d3 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_DICTIONARY2
 5
 6insert
 7   EIFFELTEST_TOOLS
 8
 9create {}
10   make
11
12feature {ANY}
13   k1: STRING "k1"
14   k2: STRING "k2"
15   k3: STRING "k3"
16   k4: STRING "k4"
17
18   v1: STRING "v1"
19   v2: STRING "v2"
20   v3: STRING "v3"
21   v4: STRING "v4"
22
23   test (d: DICTIONARY[STRING, STRING])
24      local
25         k, v: STRING; i: INTEGER; v_list, k_list: ARRAY[STRING]
26      do
27         d.put(v1, k1)
28         d.put(v2, k2)
29         d.put(v3, k3)
30         d.put(v4, k4)
31         from
32            v_list := {ARRAY[STRING] 1, << v1, v2, v3, v4 >> }
33            k_list := {ARRAY[STRING] 1, << k1, k2, k3, k4 >> }
34            i := 1
35         invariant
36            v_list.count = k_list.count
37         variant
38            v_list.count - 1
39         until
40            i > d.count
41         loop
42            v := d.item(i)
43            k := d.key(i)
44            v_list.remove(v_list.fast_first_index_of(v))
45            k_list.remove(k_list.fast_first_index_of(k))
46            i := i + 1
47         end
48         assert(v_list.is_empty)
49         assert(k_list.is_empty)
50      end
51
52   make
53      do
54         test(create {ARRAY_DICTIONARY[STRING, STRING]}.make)
55         test(create {HASHED_DICTIONARY[STRING, STRING]}.make)
56         test(create {PYTHON_DICTIONARY[STRING, STRING]}.make)
57      end
58
59end -- class TEST_DICTIONARY2
60--
61-- ------------------------------------------------------------------------------------------------------------------------------
62-- Copyright notice below. Please read.
63--
64-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
65-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
66-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
67-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
68-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
69-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
70--
71-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
72-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
73--
74-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
75--
76-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
77-- ------------------------------------------------------------------------------------------------------------------------------