1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
11 module test_abstract_text
is test
19 private var factories
: Collection[TextFactory] = [
24 fun test_escape_to_c
is test
do
26 assert f
.create
("abAB12<>&").escape_to_c
== "abAB12<>&"
27 assert f
.create
("\n\"'\\").escape_to_c == "\\n\\\"\\'\\\\
"
28 assert f.create("allo
???!").escape_to_c == "allo
??\\
?!"
29 assert f.create("??=??/??'??(??)").escape_to_c == "?\\?=?\\?/??\\'?\\
?(?\\
?)"
30 assert f.create("??!??<??>??-").escape_to_c == "?\\
?!?\\
?<?\\
?>?\\
?-"
35 # A factory that creates instances of a particular implementation of `Text`
38 # Create a `Text` instance from the specified string
39 fun create(s: String): Text is abstract
46 redef fun create(s) do return new Concat("", s)
48 class FlatBufferFactory
51 redef fun create(s) do return new FlatBuffer.from(s)