/test/lib/storage/collection/test_array_resize.e

http://github.com/tybor/Liberty · Specman e · 83 lines · 55 code · 7 blank · 21 comment · 0 complexity · 4fcd4270cc14647b2deff8f911e3f55f 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_RESIZE
  5. insert
  6. EIFFELTEST_TOOLS
  7. create {}
  8. make
  9. feature {ANY}
  10. ti1, ti2: ARRAY[INTEGER]
  11. tc1, tc2: ARRAY[CAT]
  12. c1, c2, c3, c4, c5, c6: CAT
  13. make
  14. do
  15. ti1 := {ARRAY[INTEGER] 1, << 1, 2, 3, 4, 5, 6, 7, 8, 9 >> }
  16. ti2 := {ARRAY[INTEGER] 1, << 1, 2, 3, 4, 5, 6, 7, 8, 9 >> }
  17. ti1.resize(2, 9)
  18. assert(ti1.is_equal(ti2.subarray(2, 9)))
  19. ti1.resize(2, 8)
  20. assert(ti1.is_equal(ti2.subarray(2, 8)))
  21. ti1.resize(3, 7)
  22. assert(ti1.is_equal(ti2.subarray(3, 7)))
  23. ti1.resize(1, 9)
  24. assert(ti1.is_equal({ARRAY[INTEGER] 1, << 0, 0, 3, 4, 5, 6, 7, 0, 0 >> }))
  25. ti1.resize(1, 10)
  26. assert(ti1.is_equal({ARRAY[INTEGER] 1, << 0, 0, 3, 4, 5, 6, 7, 0, 0, 0 >> }))
  27. ti1.make(1, 9)
  28. assert(ti1.is_equal({ARRAY[INTEGER] 1, << 0, 0, 0, 0, 0, 0, 0, 0, 0 >> }))
  29. create c1
  30. create c2
  31. create c3
  32. create c4
  33. create c5
  34. create c6
  35. tc1 := {ARRAY[CAT] 1, << c1, c2, c3, c4, c5, c6 >> }
  36. tc2 := {ARRAY[CAT] 2, << c2, c3, c4, c5, c6 >> }
  37. tc1.resize(2, 6)
  38. assert(tc1.is_equal(tc2))
  39. tc2 := {ARRAY[CAT] 1, << c1, c2, c3, c4, c5, c6 >> }
  40. assert(tc1.is_equal(tc2.subarray(2, 6)))
  41. tc1.resize(2, 5)
  42. assert(tc1.is_equal(tc2.subarray(2, 5)))
  43. tc1.resize(3, 4)
  44. assert(tc1.is_equal(tc2.subarray(3, 4)))
  45. tc1.resize(1, 6)
  46. assert(tc1.is_equal({ARRAY[CAT] 1, << Void, Void, c3, c4, Void, Void >> }))
  47. tc1.resize(1, 7)
  48. assert(tc1.is_equal({ARRAY[CAT] 1, << Void, Void, c3, c4, Void, Void, Void >> }))
  49. tc1.make(1, 6)
  50. tc2.clear_all
  51. assert(tc1.is_equal(tc2))
  52. tc1 := {ARRAY[CAT] 1, << c1, c2, c3, c4, c5, c6 >> }
  53. tc2 := tc1.subarray(1, 0)
  54. assert(tc2.is_empty)
  55. tc2 := tc1.subarray(3, 2)
  56. assert(tc2.is_empty)
  57. end
  58. end -- class TEST_ARRAY_RESIZE
  59. --
  60. -- ------------------------------------------------------------------------------------------------------------------------------
  61. -- Copyright notice below. Please read.
  62. --
  63. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  64. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  65. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  66. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  67. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  68. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  69. --
  70. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  71. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  72. --
  73. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  74. --
  75. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  76. -- ------------------------------------------------------------------------------------------------------------------------------