/test/language/unclassified/test_add1.e
Specman e | 112 lines | 84 code | 6 blank | 22 comment | 1 complexity | bb0960344487fa022d93ed8cbd1d547d 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_ADD1 5 6create {} 7 make 8 9feature {ANY} 10 make 11 local 12 a: ARRAY[INTEGER]; fa: FAST_ARRAY[INTEGER]; ll: LINKED_LIST[INTEGER]; l2l: TWO_WAY_LINKED_LIST[INTEGER] 13 do 14 create a.make(1, 0) 15 test(a) 16 create a.make(-1, -2) 17 test(a) 18 create fa.make(0) 19 test(fa) 20 create ll.make 21 test(ll) 22 create l2l.make 23 test(l2l) 24 end 25 26feature {} 27 test (c: COLLECTION[INTEGER]) 28 do 29 assert(c.count = 0) 30 c.add(3, c.lower) 31 assert(c.first = 3) 32 assert(c.last = 3) 33 assert(c.count = 1) 34 c.add(2, c.lower) 35 assert(c.first = 2) 36 assert(c.last = 3) 37 assert(c.count = 2) 38 c.add(1, c.lower) 39 assert(c.first = 1) 40 assert(c.item(c.lower + 1) = 2) 41 assert(c.last = 3) 42 assert(c.count = 3) 43 c.add(5, c.upper + 1) 44 assert(c.first = 1) 45 assert(c.item(c.lower + 1) = 2) 46 assert(c.item(c.lower + 2) = 3) 47 assert(c.last = 5) 48 assert(c.count = 4) 49 c.add(4, c.upper) 50 assert(c.first = 1) 51 assert(c.item(c.lower + 1) = 2) 52 assert(c.item(c.lower + 2) = 3) 53 assert(c.item(c.lower + 3) = 4) 54 assert(c.last = 5) 55 assert(c.count = 5) 56 c.clear_count 57 assert(c.count = 0) 58 c.add(1, c.lower) 59 assert(c.first = 1) 60 assert(c.last = 1) 61 assert(c.count = 1) 62 c.add(2, c.upper + 1) 63 assert(c.first = 1) 64 assert(c.last = 2) 65 assert(c.count = 2) 66 c.add(3, c.upper + 1) 67 assert(c.first = 1) 68 assert(c.item(c.upper - 1) = 2) 69 assert(c.last = 3) 70 assert(c.count = 3) 71 c.add(4, c.lower + 1) 72 assert(c.count = 4) 73 assert(c.item(c.lower + 0) = 1) 74 assert(c.item(c.lower + 1) = 4) 75 assert(c.item(c.lower + 2) = 2) 76 assert(c.item(c.lower + 3) = 3) 77 end 78 79 assert (b: BOOLEAN) 80 do 81 cpt := cpt + 1 82 if not b then 83 std_output.put_string("TEST_ADD1: ERROR Test # ") 84 std_output.put_integer(cpt) 85 std_output.put_string("%N") 86 crash 87 else 88 -- std_output.put_string("Yes%N"); 89 end 90 end 91 92 cpt: INTEGER 93 94end -- class TEST_ADD1 95-- 96-- ------------------------------------------------------------------------------------------------------------------------------ 97-- Copyright notice below. Please read. 98-- 99-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 100-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 101-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 102-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 103-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 104-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 105-- 106-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 107-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 108-- 109-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 110-- 111-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 112-- ------------------------------------------------------------------------------------------------------------------------------