/test/lib/storage/collection/test_index_of1.e

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