/test/lib/string/test_character2.e

http://github.com/tybor/Liberty · Specman e · 90 lines · 65 code · 4 blank · 21 comment · 1 complexity · 775640fca5a03ebaee83311343f319f9 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_CHARACTER2
  5. insert
  6. EIFFELTEST_TOOLS
  7. create {}
  8. make
  9. feature {ANY}
  10. make
  11. local
  12. str: STRING; c: CHARACTER; i, j: INTEGER
  13. do
  14. str := 0.to_character.to_hexadecimal
  15. assert(("00").is_equal(str))
  16. str := 1.to_character.to_hexadecimal
  17. assert(("01").is_equal(str))
  18. str := 254.to_character.to_hexadecimal
  19. assert(("FE").is_equal(str))
  20. str := 255.to_character.to_hexadecimal
  21. assert(("FF").is_equal(str))
  22. i := 0
  23. c := i.to_character
  24. assert(c.code = 0)
  25. i := 1
  26. c := i.to_character
  27. assert(c.code = 1)
  28. i := 127
  29. c := i.to_character
  30. assert(c.code = 127)
  31. i := 128
  32. c := i.to_character
  33. assert(c.code = 128)
  34. i := 254
  35. c := i.to_character
  36. assert(c.code = 254)
  37. i := 255
  38. c := i.to_character
  39. assert(c.code = 255)
  40. from
  41. c := c.default
  42. assert(c = '%U')
  43. i := 0
  44. until
  45. i >= 255
  46. loop
  47. assert(i = c.code)
  48. c := c.next
  49. i := i + 1
  50. end
  51. from
  52. c := c.default
  53. assert(c = '%U')
  54. i := 0
  55. until
  56. i >= 255
  57. loop
  58. j := c.to_integer_8
  59. if i <= 127 then
  60. assert(i = c.to_integer_8)
  61. else
  62. assert(i - 256 = c.to_integer_8)
  63. end
  64. c := c.next
  65. i := i + 1
  66. end
  67. end
  68. end -- class TEST_CHARACTER2
  69. --
  70. -- ------------------------------------------------------------------------------------------------------------------------------
  71. -- Copyright notice below. Please read.
  72. --
  73. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  74. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  75. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  76. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  77. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  78. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  79. --
  80. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  81. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  82. --
  83. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  84. --
  85. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  86. -- ------------------------------------------------------------------------------------------------------------------------------