aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/utf8.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/testes/utf8.lua b/testes/utf8.lua
index 461e223c..7472cfd0 100644
--- a/testes/utf8.lua
+++ b/testes/utf8.lua
@@ -97,9 +97,15 @@ do -- error indication in utf8.len
97 assert(not a and b == p) 97 assert(not a and b == p)
98 end 98 end
99 check("abc\xE3def", 4) 99 check("abc\xE3def", 4)
100 check("汉字\x80", #("汉字") + 1)
101 check("\xF4\x9F\xBF", 1) 100 check("\xF4\x9F\xBF", 1)
102 check("\xF4\x9F\xBF\xBF", 1) 101 check("\xF4\x9F\xBF\xBF", 1)
102 -- spurious continuation bytes
103 check("汉字\x80", #("汉字") + 1)
104 check("\x80hello", 1)
105 check("hel\x80lo", 4)
106 check("汉字\xBF", #("汉字") + 1)
107 check("\xBFhello", 1)
108 check("hel\xBFlo", 4)
103end 109end
104 110
105-- errors in utf8.codes 111-- errors in utf8.codes
@@ -112,12 +118,16 @@ do
112 end 118 end
113 errorcodes("ab\xff") 119 errorcodes("ab\xff")
114 errorcodes("\u{110000}") 120 errorcodes("\u{110000}")
121 errorcodes("in\x80valid")
122 errorcodes("\xbfinvalid")
123 errorcodes("αλφ\xBFα")
115 124
116 -- calling interation function with invalid arguments 125 -- calling interation function with invalid arguments
117 local f = utf8.codes("") 126 local f = utf8.codes("")
118 assert(f("", 2) == nil) 127 assert(f("", 2) == nil)
119 assert(f("", -1) == nil) 128 assert(f("", -1) == nil)
120 assert(f("", math.mininteger) == nil) 129 assert(f("", math.mininteger) == nil)
130
121end 131end
122 132
123-- error in initial position for offset 133-- error in initial position for offset