PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/test/lib/string/test_fixed_string.e

http://github.com/tybor/Liberty
Specman e | 40 lines | 33 code | 7 blank | 0 comment | 0 complexity | a12b120e0b272840b1ff1a363906abbd MD5 | raw file
 1class TEST_FIXED_STRING
 2
 3insert
 4   EIFFELTEST_TOOLS
 5   STRING_HANDLER
 6
 7create {}
 8   make
 9
10feature {}
11   make
12      local
13         fs: FIXED_STRING; s: STRING; p: POINTER
14      do
15         s := "foo"
16         fs := s.intern
17         assert(s.is_equal(fs))
18
19         fs := "foobar".intern.substring(2, 4)
20         assert(fs.is_shared)
21         assert(fs.is_equal("oob"))
22         assert(fs.out.is_equal("oob"))
23         assert(fs.substring(1, 1).is_equal("o"))
24
25         fs.unshare
26         assert(not fs.is_shared)
27         assert(fs.is_equal("oob"))
28         assert(fs.out.is_equal("oob"))
29         assert(fs.substring(1, 1).is_equal("o"))
30
31         fs := "riri fifi loulou".intern.substring(6, 9)
32         assert(fs.is_equal("fifi"))
33         assert(fs.is_shared)
34         p := fs.to_external
35         assert(not fs.is_shared)
36         create s.from_external(p) -- NOTE: don't do that in real code! you'll end up with a shared storage with a way to change a fixed string
37         assert(s.is_equal("fifi"))
38      end
39
40end -- class TEST_FIXED_STRING