PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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