/test/lib/numeric/mutable_big_integer/test_mutable_big_integer6.e

http://github.com/tybor/Liberty · Specman e · 86 lines · 54 code · 8 blank · 24 comment · 1 complexity · 4e8690f3160920ed16bcbd029756b874 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_MUTABLE_BIG_INTEGER6
  5. --
  6. -- Testing `hash_code' and `copy'.
  7. --
  8. insert
  9. ANY
  10. PLATFORM
  11. create {}
  12. make
  13. feature {}
  14. dictionary1: HASHED_DICTIONARY[MUTABLE_BIG_INTEGER, INTEGER_64]
  15. dictionary2: HASHED_DICTIONARY[INTEGER_64, MUTABLE_BIG_INTEGER]
  16. make
  17. local
  18. mbi1, mbi2, mbi3: MUTABLE_BIG_INTEGER; v1, v2: INTEGER_64
  19. do
  20. create dictionary1.make
  21. create dictionary2.make
  22. v1 := Maximum_integer_64
  23. create mbi1.from_integer_64(v1)
  24. dictionary1.put(mbi1, v1)
  25. dictionary2.put(v1, mbi1)
  26. assert(dictionary1.reference_at(v1) = mbi1)
  27. assert(dictionary2.at(mbi1) = v1)
  28. v2 := Minimum_integer_64
  29. create mbi2.from_integer_64(v2)
  30. dictionary1.put(mbi2, v2)
  31. dictionary2.put(v2, mbi2)
  32. assert(dictionary1.reference_at(v1) = mbi1)
  33. assert(dictionary2.at(mbi1) = v1)
  34. assert(dictionary1.reference_at(v2) = mbi2)
  35. assert(dictionary2.at(mbi2) = v2)
  36. mbi3 := mbi1.twin
  37. assert(mbi1.is_equal(mbi3))
  38. mbi3.from_integer(2)
  39. assert(not mbi1.is_equal(mbi3))
  40. mbi1.from_integer(2)
  41. assert(mbi1.is_equal(mbi3))
  42. mbi1.swap_with(mbi3)
  43. assert(mbi1.is_equal(mbi3))
  44. mbi3.from_integer(6)
  45. assert(not mbi1.is_equal(mbi3))
  46. mbi1.from_integer(6)
  47. assert(mbi1.is_equal(mbi3))
  48. end
  49. count: INTEGER
  50. assert (b: BOOLEAN)
  51. do
  52. count := count + 1
  53. if not b then
  54. sedb_breakpoint
  55. io.put_string("TEST_MUTABLE_BIG_INTEGER6 : ERROR Test # ")
  56. io.put_integer(count)
  57. io.put_string("%N")
  58. end
  59. end
  60. end -- class TEST_MUTABLE_BIG_INTEGER6
  61. --
  62. -- ------------------------------------------------------------------------------------------------------------------------------
  63. -- Copyright notice below. Please read.
  64. --
  65. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  66. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  67. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  68. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  69. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  70. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  71. --
  72. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  73. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  74. --
  75. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  76. --
  77. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  78. -- ------------------------------------------------------------------------------------------------------------------------------