/test/lib/string/test_string2.e

http://github.com/tybor/Liberty · Specman e · 66 lines · 41 code · 4 blank · 21 comment · 0 complexity · 544df4046ea744f1deed58c02025a6bc 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_STRING2
  5. insert
  6. EIFFELTEST_TOOLS
  7. create {}
  8. make
  9. feature {ANY}
  10. make
  11. local
  12. s1, s2: STRING
  13. do
  14. create s1.copy("kiki")
  15. assert(s1.is_equal("kiki"))
  16. create s2.copy(s1)
  17. assert(s1 /= s2)
  18. assert(s1.is_equal(s2))
  19. s1 := s2
  20. create s2.copy(s2)
  21. assert(s1 /= s2)
  22. assert(s1.is_equal(s2))
  23. create s1.make(25)
  24. assert(s1.capacity >= 25)
  25. assert(s1.count = 0)
  26. create s1.make_filled(' ', 25)
  27. assert(s1.capacity >= 25)
  28. assert(s1.occurrences(' ') = 25)
  29. assert(s1.count = 25)
  30. create s1.make(1)
  31. assert(s1.capacity >= 1)
  32. assert(s1.count = 0)
  33. s1.extend('x')
  34. assert(s1.count = 1)
  35. s1 := "foo.c"
  36. s1.remove_suffix(".c")
  37. assert(s1.is_equal("foo"))
  38. assert(("foo bar").has_prefix("foo"))
  39. assert(("foo bar").has_prefix(""))
  40. assert(("foo bar").has_suffix(""))
  41. assert(not ("foo").has_prefix("foo bar"))
  42. assert(not ("foo bar").has_prefix(" foo"))
  43. end
  44. end -- class TEST_STRING2
  45. --
  46. -- ------------------------------------------------------------------------------------------------------------------------------
  47. -- Copyright notice below. Please read.
  48. --
  49. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  50. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  51. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  52. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  53. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  54. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  55. --
  56. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  57. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  58. --
  59. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  60. --
  61. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  62. -- ------------------------------------------------------------------------------------------------------------------------------