/test/lib/storage/dictionary/test_avl.e
Specman e | 117 lines | 87 code | 9 blank | 21 comment | 0 complexity | 66e2239d09450f5aa5c24a2a9a2b3c56 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_AVL 5 6inherit 7 EIFFELTEST_TOOLS 8 9create {} 10 make 11 12feature {} 13 make 14 do 15 test_dictionary 16 test_set 17 end 18 19 test_dictionary 20 local 21 dico: AVL_DICTIONARY[STRING, STRING] 22 iter: ITERATOR[STRING] 23 do 24 create dico.make 25 dico.add("W", "B") 26 dico.add("X", "A") 27 dico.add("Z", "@") 28 dico.add("Y", "C") 29 assert(dico.at("B").same_as("W")) 30 assert(dico.at("A").same_as("X")) 31 assert(dico.at("C").same_as("Y")) 32 assert(dico.at("@").same_as("Z")) 33 34 iter := dico.new_iterator_on_keys 35 iter.start 36 assert(not iter.is_off) 37 assert(iter.item.same_as("@")) 38 iter.next 39 assert(not iter.is_off) 40 assert(iter.item.same_as("A")) 41 iter.next 42 assert(not iter.is_off) 43 assert(iter.item.same_as("B")) 44 iter.next 45 assert(not iter.is_off) 46 assert(iter.item.same_as("C")) 47 iter.next 48 assert(iter.is_off) 49 50 iter := dico.new_iterator_on_items 51 iter.start 52 assert(not iter.is_off) 53 assert(iter.item.same_as("Z")) 54 iter.next 55 assert(not iter.is_off) 56 assert(iter.item.same_as("X")) 57 iter.next 58 assert(not iter.is_off) 59 assert(iter.item.same_as("W")) 60 iter.next 61 assert(not iter.is_off) 62 assert(iter.item.same_as("Y")) 63 iter.next 64 assert(iter.is_off) 65 end 66 67 test_set 68 local 69 set: AVL_SET[STRING] 70 iter: ITERATOR[STRING] 71 do 72 create set.make 73 set.add("B") 74 set.add("A") 75 set.add("@") 76 set.add("C") 77 assert(set.has("@")) 78 assert(set.has("A")) 79 assert(set.has("B")) 80 assert(set.has("C")) 81 82 iter := set.new_iterator 83 iter.start 84 assert(not iter.is_off) 85 assert(iter.item.same_as("@")) 86 iter.next 87 assert(not iter.is_off) 88 assert(iter.item.same_as("A")) 89 iter.next 90 assert(not iter.is_off) 91 assert(iter.item.same_as("B")) 92 iter.next 93 assert(not iter.is_off) 94 assert(iter.item.same_as("C")) 95 iter.next 96 assert(iter.is_off) 97 end 98 99end -- class TEST_AVL 100-- 101-- ------------------------------------------------------------------------------------------------------------------------------ 102-- Copyright notice below. Please read. 103-- 104-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 105-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 106-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 107-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 108-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 109-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 110-- 111-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 112-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 113-- 114-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 115-- 116-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 117-- ------------------------------------------------------------------------------------------------------------------------------