tests: Test for UTF-8 Strings.
authorLucas Bajolet <r4pass@hotmail.com>
Thu, 17 Jul 2014 17:54:23 +0000 (13:54 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 29 Jul 2014 16:01:03 +0000 (12:01 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

tests/sav/utf_test.res [new file with mode: 0644]
tests/utf_test.nit [new file with mode: 0644]

diff --git a/tests/sav/utf_test.res b/tests/sav/utf_test.res
new file mode 100644 (file)
index 0000000..4055d93
--- /dev/null
@@ -0,0 +1,11 @@
+28
+すでa語A本日a 𐍆,A ᓂ . ᓀ 界世a𐍃ーЖロaハ
+ハaロЖー𐍃a世界 ᓀ . ᓂ A,𐍆 a日本A語aです
+ー𐍃a世
+30fc
+10343
+61
+4e16
+ハAロЖー𐍃A世界 ᓀ . ᓂ A,𐍆 A日本A語Aです
+ハaロЖー𐍃a世界 ᓀ . ᓂ a,𐍆 a日本a語aです
+ハaロЖー𐍃a世界 ᓀ . ᓂ A,𐍆 a日本A語aですハaロЖー𐍃a世界 ᓀ . ᓂ A,𐍆 a日本A語aです
diff --git a/tests/utf_test.nit b/tests/utf_test.nit
new file mode 100644 (file)
index 0000000..88474c4
--- /dev/null
@@ -0,0 +1,42 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# This file is free software, which comes along with NIT.  This software is
+# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
+# PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
+# is kept unaltered, and a notification of the changes is added.
+# You  are  allowed  to  redistribute it and sell it, alone or is a part of
+# another product.
+
+import standard
+intrude import string_experimentations::utf8
+
+var s = "aàハ𐍆".as(FlatString)
+assert s.index[0].code_point == 97
+assert s.index[1].code_point == 224
+assert s.index[2].code_point == 12495
+assert s.index[3].code_point == 66374
+
+var str = "ハaロЖー𐍃a世界 ᓀ . ᓂ A,𐍆 a日本A語aです".as(FlatString)
+
+print str.length
+
+print str.reversed
+
+str.output
+
+print ""
+
+var x = str.substring(4,4).as(FlatString)
+
+print x
+
+for i in [0..x.length[ do
+       print x.index[i + x.index_from].code_point.to_hex
+end
+
+print str.to_upper
+
+print str.to_lower
+
+print str * 2