/test/lib/numeric/real/test_double6.e

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