/test/lib/storage/dictionary/test_dictionary2.e

http://github.com/tybor/Liberty · Specman e · 77 lines · 49 code · 7 blank · 21 comment · 0 complexity · e77253f547f0900b65610e7eb65a84d3 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_DICTIONARY2
  5. insert
  6. EIFFELTEST_TOOLS
  7. create {}
  8. make
  9. feature {ANY}
  10. k1: STRING "k1"
  11. k2: STRING "k2"
  12. k3: STRING "k3"
  13. k4: STRING "k4"
  14. v1: STRING "v1"
  15. v2: STRING "v2"
  16. v3: STRING "v3"
  17. v4: STRING "v4"
  18. test (d: DICTIONARY[STRING, STRING])
  19. local
  20. k, v: STRING; i: INTEGER; v_list, k_list: ARRAY[STRING]
  21. do
  22. d.put(v1, k1)
  23. d.put(v2, k2)
  24. d.put(v3, k3)
  25. d.put(v4, k4)
  26. from
  27. v_list := {ARRAY[STRING] 1, << v1, v2, v3, v4 >> }
  28. k_list := {ARRAY[STRING] 1, << k1, k2, k3, k4 >> }
  29. i := 1
  30. invariant
  31. v_list.count = k_list.count
  32. variant
  33. v_list.count - 1
  34. until
  35. i > d.count
  36. loop
  37. v := d.item(i)
  38. k := d.key(i)
  39. v_list.remove(v_list.fast_first_index_of(v))
  40. k_list.remove(k_list.fast_first_index_of(k))
  41. i := i + 1
  42. end
  43. assert(v_list.is_empty)
  44. assert(k_list.is_empty)
  45. end
  46. make
  47. do
  48. test(create {ARRAY_DICTIONARY[STRING, STRING]}.make)
  49. test(create {HASHED_DICTIONARY[STRING, STRING]}.make)
  50. test(create {PYTHON_DICTIONARY[STRING, STRING]}.make)
  51. end
  52. end -- class TEST_DICTIONARY2
  53. --
  54. -- ------------------------------------------------------------------------------------------------------------------------------
  55. -- Copyright notice below. Please read.
  56. --
  57. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  58. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  59. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  60. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  61. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  62. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  63. --
  64. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  65. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  66. --
  67. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  68. --
  69. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  70. -- ------------------------------------------------------------------------------------------------------------------------------