/test/lib/storage/collection/test_array2.e
Specman e | 122 lines | 94 code | 6 blank | 22 comment | 3 complexity | 0bb2d60ed39471f0cff85b751d3a632d 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_ARRAY2 5 6create {} 7 make 8 9feature {ANY} 10 a, b: ARRAY2[INTEGER_8] 11 12 make 13 local 14 i1, i2: INTEGER; v: INTEGER_8 15 do 16 create a.make(1, 2, 3, 4) 17 assert(a.count = 4) 18 assert(a.lower1 = 1) 19 assert(a.upper1 = 2) 20 assert(a.lower2 = 3) 21 assert(a.upper2 = 4) 22 assert(a.item(1, 3) = 0) 23 create a.make(1, 3, 1, 3) 24 assert(a.count = 9) 25 assert(a.lower1 = 1) 26 assert(a.upper1 = 3) 27 assert(a.lower1 = 1) 28 assert(a.upper2 = 3) 29 b := {ARRAY2[INTEGER_8] 1, 3, 1, 3, << 0, 0, 0; 30 0, 0, 0; 31 0, 0, 0 >> } 32 assert(b.count = 9) 33 assert(b.lower1 = 1) 34 assert(b.upper1 = 3) 35 assert(b.lower1 = 1) 36 assert(b.upper2 = 3) 37 assert(a.is_equal(b)) 38 assert(a.is_equal(b)) 39 from 40 a := {ARRAY2[INTEGER_8] 1, 3, 1, 3, << 1, 2, 3; 41 4, 5, 6; 42 7, 8, 9 >> } 43 i1 := a.lower1 44 i2 := a.lower2 45 v := 1 46 until 47 v > 9 48 loop 49 assert(v = a.item(i1, i2)) 50 v := v + 1 51 if i2 = a.upper2 then 52 i1 := i1 + 1 53 i2 := a.lower2 54 else 55 i2 := i2 + 1 56 end 57 end 58 from 59 b := a.twin 60 i1 := a.lower1 61 i2 := a.lower2 62 v := 1 63 until 64 v > 9 65 loop 66 assert(v = a.item(i1, i2)) 67 assert(v = b.item(i1, i2)) 68 v := v + 1 69 if i2 = a.upper2 then 70 i1 := i1 + 1 71 i2 := a.lower2 72 else 73 i2 := i2 + 1 74 end 75 end 76 assert(a.is_equal(b)) 77 b.put(0, 2, 2) 78 assert(not a.is_equal(b)) 79 a := {ARRAY2[INTEGER_8] 1, 3, 1, 3, << 1, 2, 2; 80 4, 5, 6; 81 7, 8, 9 >> } 82 assert(a.occurrences(2) = 2) 83 assert(a.occurrences(3) = 0) 84 assert(a.occurrences(4) = 1) 85 assert(a.fast_occurrences(2) = 2) 86 assert(a.fast_occurrences(3) = 0) 87 assert(a.fast_occurrences(4) = 1) 88 end 89 90 assert (bool: BOOLEAN) 91 do 92 cpt := cpt + 1 93 if not bool then 94 std_output.put_string("TEST_ARRAY2: ERROR Test # ") 95 std_output.put_integer(cpt) 96 std_output.put_string("%N") 97 else 98 -- std_output.put_string("Yes%N"); 99 end 100 end 101 102 cpt: INTEGER 103 104end -- class TEST_ARRAY2 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-- ------------------------------------------------------------------------------------------------------------------------------