PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/storage/collection/test_from_collection1.e

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