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