PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/collection/test_subarray1.e

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