/test/language/unclassified/test_add1.e

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