PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/dictionary/test_linked_hashed_dictionary.e

http://github.com/tybor/Liberty
Specman e | 53 lines | 42 code | 11 blank | 0 comment | 0 complexity | 553641d644ba2c0c7f4215be3cdab650 MD5 | raw file
 1class TEST_LINKED_HASHED_DICTIONARY
 2
 3insert
 4   EIFFELTEST_TOOLS
 5
 6create {}
 7   make
 8
 9feature {}
10   make
11      local
12         dict: LINKED_HASHED_DICTIONARY[INTEGER, STRING]
13         list_keys: FAST_ARRAY[STRING]
14         list_items: FAST_ARRAY[INTEGER]
15      do
16         create dict.make
17         dict.add(1, "first")
18         dict.add(2, "second")
19         dict.add(3, "third")
20
21         create list_keys.make(0)
22         dict.key_map_in(list_keys)
23         assert(list_keys.item(0).is_equal("first"))
24         assert(list_keys.item(1).is_equal("second"))
25         assert(list_keys.item(2).is_equal("third"))
26
27         create list_items.make(0)
28         dict.item_map_in(list_items)
29         assert(list_items.item(0) = 1)
30         assert(list_items.item(1) = 2)
31         assert(list_items.item(2) = 3)
32
33         assert(dict.new_iterator_on_keys.for_all(agent check_list_keys(?, list_keys)))
34         assert(dict.new_iterator_on_items.for_all(agent check_list_items(?, list_items)))
35      end
36
37   check_list_keys (key: STRING; list_keys: COLLECTION[STRING]): BOOLEAN
38      do
39         Result := list_keys.item(list_key_index).is_equal(key)
40         list_key_index := list_key_index + 1
41      end
42
43   list_key_index: INTEGER
44
45   check_list_items (item: INTEGER; list_items: COLLECTION[INTEGER]): BOOLEAN
46      do
47         Result := list_items.item(list_item_index) = item
48         list_item_index := list_item_index + 1
49      end
50
51   list_item_index: INTEGER
52
53end