/test/lib/numeric/mutable_big_integer/test_mutable_big_integer11.e

http://github.com/tybor/Liberty · Specman e · 76 lines · 46 code · 6 blank · 24 comment · 1 complexity · 587eb31cad863dedb3dca67479e3ada8 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_INTEGER11
  5. --
  6. -- Testing feature `add' when magnitude must grow up.
  7. --
  8. insert
  9. ANY
  10. PLATFORM
  11. create {}
  12. make
  13. feature {ANY}
  14. make
  15. local
  16. mbia, mbib, mbir, mbiq: MUTABLE_BIG_INTEGER; i: INTEGER_64
  17. do
  18. create mbia.from_integer_64(Maximum_integer_64)
  19. create mbib.from_integer_64(Maximum_integer_64)
  20. create mbiq.from_integer(13)
  21. create mbir.from_integer(12)
  22. from
  23. i := 0
  24. until
  25. i = 100
  26. loop
  27. mbia.add(mbia)
  28. i := i + 1
  29. end
  30. mbib.shift_left(100)
  31. assert(mbia.is_equal(mbib))
  32. mbia.divide_to(mbia, mbiq, mbir)
  33. assert(mbiq.is_one)
  34. assert(mbir.is_zero)
  35. mbia.multiply_to(mbib, mbir)
  36. assert(mbia.is_equal(mbib))
  37. mbir.divide_to(mbia, mbiq, mbib)
  38. assert(mbia.is_equal(mbiq))
  39. assert(mbib.is_zero)
  40. end
  41. count: INTEGER
  42. assert (b: BOOLEAN)
  43. do
  44. count := count + 1
  45. if not b then
  46. sedb_breakpoint
  47. io.put_string("TEST_MUTABLE_BIG_INTEGER11 : ERROR Test # ")
  48. io.put_integer(count)
  49. io.put_string("%N")
  50. end
  51. end
  52. end -- class TEST_MUTABLE_BIG_INTEGER11
  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. -- ------------------------------------------------------------------------------------------------------------------------------