/test/lib/storage/dictionary/test_dictionary7.e

http://github.com/tybor/Liberty · Specman e · 122 lines · 92 code · 9 blank · 21 comment · 0 complexity · f4965fe5fcfde9a42742024f34aa5045 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_DICTIONARY7
  5. insert
  6. EIFFELTEST_TOOLS
  7. create {}
  8. make
  9. feature {ANY}
  10. test (d: DICTIONARY[INTEGER, INTEGER])
  11. do
  12. buffer.clear_count
  13. d.key_map_in(buffer)
  14. assert(buffer.count = 0)
  15. d.item_map_in(buffer)
  16. assert(buffer.count = 0)
  17. d.put(1, 1)
  18. buffer.clear_count
  19. d.key_map_in(buffer)
  20. assert(buffer.count = 1)
  21. assert(buffer.first = 1)
  22. buffer.clear_count
  23. d.item_map_in(buffer)
  24. assert(buffer.count = 1)
  25. assert(buffer.first = 1)
  26. d.put(2, 2)
  27. buffer.clear_count
  28. d.key_map_in(buffer)
  29. sorter.sort(buffer)
  30. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1.to_integer_32, 2 >> }))
  31. buffer.clear_count
  32. d.item_map_in(buffer)
  33. sorter.sort(buffer)
  34. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32 >> }))
  35. d.put(3, 3)
  36. buffer.clear_count
  37. d.key_map_in(buffer)
  38. sorter.sort(buffer)
  39. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2, 3 >> }))
  40. buffer.clear_count
  41. d.item_map_in(buffer)
  42. sorter.sort(buffer)
  43. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32, 3 >> }))
  44. d.put(1, 3)
  45. buffer.clear_count
  46. d.key_map_in(buffer)
  47. sorter.sort(buffer)
  48. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32, 3 >> }))
  49. buffer.clear_count
  50. d.item_map_in(buffer)
  51. buffer_view
  52. sorter.sort(buffer)
  53. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 1, 2.to_integer_32 >> }))
  54. d.put(1, 2)
  55. buffer.clear_count
  56. d.key_map_in(buffer)
  57. sorter.sort(buffer)
  58. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 2.to_integer_32, 3 >> }))
  59. buffer.clear_count
  60. d.item_map_in(buffer)
  61. buffer_view
  62. sorter.sort(buffer)
  63. assert(buffer.is_equal({ARRAY[INTEGER] 1, << 1, 1.to_integer_32, 1 >> }))
  64. end
  65. make
  66. do
  67. test(create {ARRAY_DICTIONARY[INTEGER, INTEGER]}.make)
  68. test(create {HASHED_DICTIONARY[INTEGER, INTEGER]}.make)
  69. test(create {PYTHON_DICTIONARY[INTEGER, INTEGER]}.make)
  70. end
  71. buffer: ARRAY[INTEGER]
  72. once
  73. create Result.with_capacity(12, 1)
  74. end
  75. view: STRING
  76. buffer_view
  77. local
  78. i: INTEGER
  79. do
  80. view := ("<<").twin
  81. from
  82. i := 1
  83. until
  84. i > buffer.count
  85. loop
  86. buffer.item(i).append_in(view)
  87. view.extend(' ')
  88. i := i + 1
  89. end
  90. view.append(">>")
  91. end
  92. sorter: COLLECTION_SORTER[INTEGER]
  93. once
  94. end
  95. end -- class TEST_DICTIONARY7
  96. --
  97. -- ------------------------------------------------------------------------------------------------------------------------------
  98. -- Copyright notice below. Please read.
  99. --
  100. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  101. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  102. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  103. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  104. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  105. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  106. --
  107. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  108. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  109. --
  110. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  111. --
  112. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  113. -- ------------------------------------------------------------------------------------------------------------------------------