PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/collection/test_array_expanded.e

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