/test/lib/storage/collection/test_remove_last1.e

http://github.com/tybor/Liberty · Specman e · 73 lines · 45 code · 6 blank · 22 comment · 1 complexity · 63b82bb4aa717fabc0f18e8918e7aeac 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_REMOVE_LAST1
  5. create {}
  6. make
  7. feature {ANY}
  8. make
  9. local
  10. a: ARRAY[INTEGER]; fa: FAST_ARRAY[INTEGER]; ll: LINKED_LIST[INTEGER]; l2l: TWO_WAY_LINKED_LIST[INTEGER]
  11. do
  12. a := {ARRAY[INTEGER] 1, << 1, 2, 3 >> }
  13. test(a)
  14. fa := {FAST_ARRAY[INTEGER] << 1, 2, 3 >> }
  15. test(fa)
  16. ll := {LINKED_LIST[INTEGER] << 1, 2, 3 >> }
  17. test(ll)
  18. l2l := {TWO_WAY_LINKED_LIST[INTEGER] << 1, 2, 3 >> }
  19. test(l2l)
  20. end
  21. feature {}
  22. test (c: COLLECTION[INTEGER])
  23. do
  24. assert(c.count = 3)
  25. assert(c.last = 3)
  26. c.remove_last
  27. assert(c.count = 2)
  28. assert(c.last = 2)
  29. c.remove_last
  30. assert(c.count = 1)
  31. assert(c.last = 1)
  32. c.remove_last
  33. assert(c.count = 0)
  34. assert(c.is_empty)
  35. end
  36. assert (b: BOOLEAN)
  37. do
  38. cpt := cpt + 1
  39. if not b then
  40. std_output.put_string("TEST_REMOVE_LAST1: ERROR Test # ")
  41. std_output.put_integer(cpt)
  42. std_output.put_string("%N")
  43. crash
  44. else
  45. -- std_output.put_string("Yes%N");
  46. end
  47. end
  48. cpt: INTEGER
  49. end -- class TEST_REMOVE_LAST1
  50. --
  51. -- ------------------------------------------------------------------------------------------------------------------------------
  52. -- Copyright notice below. Please read.
  53. --
  54. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  55. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  56. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  57. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  58. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  59. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  60. --
  61. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  62. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  63. --
  64. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  65. --
  66. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  67. -- ------------------------------------------------------------------------------------------------------------------------------