/test/lib/string/test_string9.e

http://github.com/tybor/Liberty · Specman e · 123 lines · 98 code · 4 blank · 21 comment · 0 complexity · 72372f0f65c711632eeeae0fac07077a 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_STRING9
  5. insert
  6. EIFFELTEST_TOOLS
  7. create {}
  8. make
  9. feature {ANY}
  10. make
  11. local
  12. str: STRING; i: INTEGER
  13. do
  14. str := "a%/0/b"
  15. i := str.count
  16. assert(i = 3)
  17. assert(str.item(2) = '%U')
  18. assert(("foo").substring_index("foo", 1) = 1)
  19. assert(("Afoo").substring_index("foo", 1) = 2)
  20. assert(("Afofoo").substring_index("foo", 1) = 4)
  21. assert(("Afofo").substring_index("foo", 1) = 0)
  22. assert(("Afofo").substring_index("", 1) = 1)
  23. assert(("Afofoofoo").substring_index("foo", 1) = 4)
  24. assert(not ("").is_real)
  25. assert(not ("").is_integer)
  26. assert(not ("").is_integer_64)
  27. assert(not (" ").is_real)
  28. assert(not (" ").is_integer)
  29. assert(not (" ").is_integer_64)
  30. assert(not ("+").is_real)
  31. assert(not ("+").is_integer)
  32. assert(not ("+").is_integer_64)
  33. assert(not ("-").is_real)
  34. assert(not ("-").is_integer)
  35. assert(not ("-").is_integer_64)
  36. assert(not ("1a").is_integer)
  37. assert(not ("1a").is_integer_64)
  38. assert(("1").is_integer)
  39. assert(("1").is_integer_64)
  40. assert(not (" + 32 1").is_integer)
  41. assert(not (" + 32 1").is_integer_64)
  42. assert(("%N-657%T").to_integer = -657)
  43. assert(("%N-657%T").to_integer_64 = -657)
  44. ("").replace_all('a', 'b')
  45. str := "ooo"
  46. str.replace_all('a', 'b')
  47. assert(str.is_equal("ooo"))
  48. str.replace_all('o', 'a')
  49. assert(str.is_equal("aaa"))
  50. str := "foo"
  51. str.extend_to_count(' ', 4)
  52. assert(("foo ").is_equal(str))
  53. str := "foo"
  54. str.precede_to_count(' ', 4)
  55. assert((" foo").is_equal(str))
  56. str := "foo"
  57. str.extend_to_count(' ', 3)
  58. assert(("foo").is_equal(str))
  59. str := "foo"
  60. str.precede_to_count(' ', 3)
  61. assert(("foo").is_equal(str))
  62. str := ""
  63. str.extend_to_count(' ', 0)
  64. assert(("").is_equal(str))
  65. str.precede_to_count(' ', 0)
  66. assert(("").is_equal(str))
  67. str := "foo"
  68. str.precede_to_count(' ', 2)
  69. assert(("foo").is_equal(str))
  70. str := "foo"
  71. str.precede_to_count(' ', 5)
  72. assert((" foo").is_equal(str))
  73. str := ""
  74. str.extend_multiple('a', 0)
  75. assert(("").is_equal(str))
  76. str.extend_multiple('b', 1)
  77. assert(("b").is_equal(str))
  78. str.extend_multiple('a', 2)
  79. assert(("baa").is_equal(str))
  80. str := ""
  81. str.precede_multiple('a',-1)
  82. assert(str ~ "")
  83. str.precede_multiple('a', 0)
  84. assert(("").is_equal(str))
  85. str.precede_multiple('b', 1)
  86. assert(("b").is_equal(str))
  87. str.precede_multiple('a', 2)
  88. assert(("aab").is_equal(str))
  89. str := "a" + "bc"
  90. assert(("abc").is_equal(str))
  91. str := "" + "bc"
  92. assert(("bc").is_equal(str))
  93. str := "ab" + ""
  94. assert(("ab").is_equal(str))
  95. str := "" + ""
  96. assert(("").is_equal(str))
  97. str := "foo"
  98. str.prepend("bar")
  99. assert(("barfoo").is_equal(str))
  100. end
  101. end -- class TEST_STRING9
  102. --
  103. -- ------------------------------------------------------------------------------------------------------------------------------
  104. -- Copyright notice below. Please read.
  105. --
  106. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  107. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  108. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  109. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  110. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  111. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  112. --
  113. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  114. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  115. --
  116. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  117. --
  118. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  119. -- ------------------------------------------------------------------------------------------------------------------------------