PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/dictionary/test_dictionary4.e

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