浏览代码

Add unit tests for haxe.Utf8.validate

Ryusei Yamaguchi 9 年之前
父节点
当前提交
9e027d3343
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      tests/unit/src/unitstd/haxe/Utf8.unit.hx

+ 11 - 0
tests/unit/src/unitstd/haxe/Utf8.unit.hx

@@ -44,6 +44,17 @@ haxe.Utf8.compare(haxe.Utf8.sub(str, 1, 0), "") == 0;
 // unspecify outside of range Utf8.sub
 // haxe.Utf8.compare(haxe.Utf8.sub(str, 9, 0), "") == 0;
 
+#if (neko || php || cpp || lua || macro)
+haxe.Utf8.validate("\xf0\xa9\xb8\xbd\xe3\x81\x82\xc3\xab\x61") == true;
+haxe.Utf8.validate("\xed\x9f\xbf") == true;
+haxe.Utf8.validate("\xee\x80\x80") == true;
+haxe.Utf8.validate("\xf4\x8f\xbf\xbf") == true;
+haxe.Utf8.validate("\xf0\xa9\xb8\xbd\xe3\x81\xc3\xab\x61") == false;
+haxe.Utf8.validate("\xc0\xaf") == false; // redundant sequence
+haxe.Utf8.validate("\xed\xa0\x80") == false; // surrogate byte sequence
+haxe.Utf8.validate("\xed\xbf\xbf") == false; // surrogate byte sequence
+haxe.Utf8.validate("\xf4\x90\x80\x80") == false; // U+110000
+#end
 
 #if php
 }