PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/test/lib/storage/dictionary/test_dictionary7.e

http://github.com/tybor/Liberty
Specman e | 122 lines | 92 code | 9 blank | 21 comment | 0 complexity | f4965fe5fcfde9a42742024f34aa5045 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_DICTIONARY7
  5
  6insert
  7   EIFFELTEST_TOOLS
  8
  9create {}
 10   make
 11
 12feature {ANY}
 13   test (d: DICTIONARY[INTEGER, INTEGER])
 14      do
 15         buffer.clear_count
 16         d.key_map_in(buffer)
 17         assert(buffer.count = 0)
 18         d.item_map_in(buffer)
 19         assert(buffer.count = 0)
 20         d.put(1, 1)
 21         buffer.clear_count
 22         d.key_map_in(buffer)
 23         assert(buffer.count = 1)
 24         assert(buffer.first = 1)
 25         buffer.clear_count
 26         d.item_map_in(buffer)
 27         assert(buffer.count = 1)
 28         assert(buffer.first = 1)
 29         d.put(2, 2)
 30         buffer.clear_count
 31         d.key_map_in(buffer)
 32         sorter.sort(buffer)
 33         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1.to_integer_32, 2 >> }))
 34         buffer.clear_count
 35         d.item_map_in(buffer)
 36         sorter.sort(buffer)
 37         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32 >> }))
 38         d.put(3, 3)
 39         buffer.clear_count
 40         d.key_map_in(buffer)
 41         sorter.sort(buffer)
 42         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2, 3 >> }))
 43         buffer.clear_count
 44         d.item_map_in(buffer)
 45         sorter.sort(buffer)
 46         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32, 3 >> }))
 47         d.put(1, 3)
 48         buffer.clear_count
 49         d.key_map_in(buffer)
 50         sorter.sort(buffer)
 51         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32, 3 >> }))
 52         buffer.clear_count
 53         d.item_map_in(buffer)
 54         buffer_view
 55         sorter.sort(buffer)
 56         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 1, 2.to_integer_32 >> }))
 57         d.put(1, 2)
 58         buffer.clear_count
 59         d.key_map_in(buffer)
 60         sorter.sort(buffer)
 61         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32, 3 >> }))
 62         buffer.clear_count
 63         d.item_map_in(buffer)
 64         buffer_view
 65         sorter.sort(buffer)
 66         assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 1.to_integer_32, 1 >> }))
 67      end
 68
 69   make
 70      do
 71         test(create {ARRAY_DICTIONARY[INTEGER, INTEGER]}.make)
 72         test(create {HASHED_DICTIONARY[INTEGER, INTEGER]}.make)
 73         test(create {PYTHON_DICTIONARY[INTEGER, INTEGER]}.make)
 74      end
 75
 76   buffer: ARRAY[INTEGER]
 77      once
 78         create Result.with_capacity(12, 1)
 79      end
 80
 81   view: STRING
 82
 83   buffer_view
 84      local
 85         i: INTEGER
 86      do
 87         view := ("<<").twin
 88         from
 89            i := 1
 90         until
 91            i > buffer.count
 92         loop
 93            buffer.item(i).append_in(view)
 94            view.extend(' ')
 95            i := i + 1
 96         end
 97         view.append(">>")
 98      end
 99
100   sorter: COLLECTION_SORTER[INTEGER]
101      once
102      end
103
104end -- class TEST_DICTIONARY7
105--
106-- ------------------------------------------------------------------------------------------------------------------------------
107-- Copyright notice below. Please read.
108--
109-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
110-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
111-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
112-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
113-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
114-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
115--
116-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
117-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
118--
119-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
120--
121-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
122-- ------------------------------------------------------------------------------------------------------------------------------