/test/lib/numeric/mutable_big_integer/test_mutable_big_integer10.e

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