/test/lib/storage/dictionary/test_dictionary4.e

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