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