utf8_noindex/tests: Added a test for utf8 without index variant
authorLucas Bajolet <r4pass@hotmail.com>
Thu, 7 Aug 2014 16:52:40 +0000 (12:52 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 12 Aug 2014 17:35:34 +0000 (13:35 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

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

diff --git a/tests/sav/utf_noindex_test.res b/tests/sav/utf_noindex_test.res
new file mode 100644 (file)
index 0000000..5877a29
--- /dev/null
@@ -0,0 +1,12 @@
+28
+ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです
+ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです
+すでaθͺžA本ζ—₯a π†,A α“‚ . α“€ η•ŒδΈ–a𐍃ーЖロaハ
+ー𐍃aδΈ–
+δΈ–a𐍃ー
+ハAロЖー𐍃AδΈ–η•Œ α“€ . α“‚ A,𐍆 Aζ—₯本AθͺžAです
+ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ a,𐍆 aζ—₯本aθͺžaです
+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_noindex_test.nit b/tests/utf_noindex_test.nit
new file mode 100644 (file)
index 0000000..a731499
--- /dev/null
@@ -0,0 +1,92 @@
+# 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_noindex
+
+var s = "aàハ𐍆".as(FlatString)
+assert s.char_at(0).code_point == 97
+assert s.char_at(1).code_point == 224
+assert s.char_at(2).code_point == 12495
+assert s.char_at(3).code_point == 66374
+
+var str = "ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです".as(FlatString)
+
+print str.length
+print str
+
+for i in [0 .. str.length[ do
+       str.char_at(i).output
+end
+
+'\n'.output
+
+var ss = str.reversed.as(FlatString)
+
+for i in [0 .. ss.length[ do ss.char_at(i).output
+
+'\n'.output
+
+var x = str.substring(4,4).as(FlatString)
+
+for i in [0 .. x.length[ do x.char_at(i).output
+
+'\n'.output
+
+var xx = x.reversed.as(FlatString)
+
+for i in [0 .. xx.length[ do xx.char_at(i).output
+
+'\n'.output
+
+assert str * 2 == str + str
+
+assert x * 2 == x + x
+
+print str.to_upper
+
+print str.to_lower
+
+var buf = new FlatBuffer.from(str)
+
+buf.append str
+
+var bf = new FlatBuffer.from(str)
+
+bf.times(2)
+
+assert bf == buf
+
+var bf2 = new FlatBuffer.from(str)
+
+bf2.char_at(0) = str.char_at(1)
+bf2.char_at(1) = str.char_at(0)
+
+for i in [0 .. bf2.length[ do bf2.char_at(i).output
+
+'\n'.output
+
+bf2.lower
+
+for i in [0 .. bf2.length[ do bf2.char_at(i).output
+
+'\n'.output
+
+bf2.upper
+
+for i in [0 .. bf2.length[ do bf2.char_at(i).output
+
+'\n'.output
+
+bf2.reverse
+
+for i in [0 .. bf2.length[ do bf2.char_at(i).output
+
+'\n'.output