diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-05-27 11:46:47 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-05-27 11:46:47 -0300 |
commit | aa8d4a782d88738b3ea921cde5a450656da8fa63 (patch) | |
tree | ecdc874d2476a40ad3857d2c03aaced9d0e04598 /testes | |
parent | efcf24be0c22cba57b298161bf4ab0561fd3c08e (diff) | |
download | lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.tar.gz lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.tar.bz2 lua-aa8d4a782d88738b3ea921cde5a450656da8fa63.zip |
Details (more uniformity in error messages)
Diffstat (limited to 'testes')
-rw-r--r-- | testes/utf8.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/testes/utf8.lua b/testes/utf8.lua index 5954f6e8..6010d1ad 100644 --- a/testes/utf8.lua +++ b/testes/utf8.lua | |||
@@ -115,17 +115,17 @@ do | |||
115 | end | 115 | end |
116 | 116 | ||
117 | -- error in initial position for offset | 117 | -- error in initial position for offset |
118 | checkerror("position out of range", utf8.offset, "abc", 1, 5) | 118 | checkerror("position out of bounds", utf8.offset, "abc", 1, 5) |
119 | checkerror("position out of range", utf8.offset, "abc", 1, -4) | 119 | checkerror("position out of bounds", utf8.offset, "abc", 1, -4) |
120 | checkerror("position out of range", utf8.offset, "", 1, 2) | 120 | checkerror("position out of bounds", utf8.offset, "", 1, 2) |
121 | checkerror("position out of range", utf8.offset, "", 1, -1) | 121 | checkerror("position out of bounds", utf8.offset, "", 1, -1) |
122 | checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) | 122 | checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) |
123 | checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) | 123 | checkerror("continuation byte", utf8.offset, "𦧺", 1, 2) |
124 | checkerror("continuation byte", utf8.offset, "\x80", 1) | 124 | checkerror("continuation byte", utf8.offset, "\x80", 1) |
125 | 125 | ||
126 | -- error in indices for len | 126 | -- error in indices for len |
127 | checkerror("out of string", utf8.len, "abc", 0, 2) | 127 | checkerror("out of bounds", utf8.len, "abc", 0, 2) |
128 | checkerror("out of string", utf8.len, "abc", 1, 4) | 128 | checkerror("out of bounds", utf8.len, "abc", 1, 4) |
129 | 129 | ||
130 | 130 | ||
131 | local s = "hello World" | 131 | local s = "hello World" |
@@ -140,11 +140,11 @@ do | |||
140 | local t = {utf8.codepoint(s,1,#s - 1)} | 140 | local t = {utf8.codepoint(s,1,#s - 1)} |
141 | assert(#t == 3 and t[1] == 225 and t[2] == 233 and t[3] == 237) | 141 | assert(#t == 3 and t[1] == 225 and t[2] == 233 and t[3] == 237) |
142 | checkerror("invalid UTF%-8 code", utf8.codepoint, s, 1, #s) | 142 | checkerror("invalid UTF%-8 code", utf8.codepoint, s, 1, #s) |
143 | checkerror("out of range", utf8.codepoint, s, #s + 1) | 143 | checkerror("out of bounds", utf8.codepoint, s, #s + 1) |
144 | t = {utf8.codepoint(s, 4, 3)} | 144 | t = {utf8.codepoint(s, 4, 3)} |
145 | assert(#t == 0) | 145 | assert(#t == 0) |
146 | checkerror("out of range", utf8.codepoint, s, -(#s + 1), 1) | 146 | checkerror("out of bounds", utf8.codepoint, s, -(#s + 1), 1) |
147 | checkerror("out of range", utf8.codepoint, s, 1, #s + 1) | 147 | checkerror("out of bounds", utf8.codepoint, s, 1, #s + 1) |
148 | -- surrogates | 148 | -- surrogates |
149 | assert(utf8.codepoint("\u{D7FF}") == 0xD800 - 1) | 149 | assert(utf8.codepoint("\u{D7FF}") == 0xD800 - 1) |
150 | assert(utf8.codepoint("\u{E000}") == 0xDFFF + 1) | 150 | assert(utf8.codepoint("\u{E000}") == 0xDFFF + 1) |