Fix JDK-dependent stdlib tests after advancing jvmTarget

This commit is contained in:
Abduqodiri Qurbonzoda
2022-08-16 13:36:04 +03:00
parent 9e35815ae3
commit 6c4777dcdd
14 changed files with 72 additions and 167 deletions
@@ -6,7 +6,6 @@
package test.text
import test.assertArrayContentEquals
import test.testOnNonJvm6And7
import kotlin.test.*
// When decoding utf-8, JVM and JS implementations replace the sequence reflecting a surrogate code point differently.
@@ -207,28 +206,26 @@ class StringEncodingTest {
testDecoding(false, "z", bytes(0xE0, 0xAF, 0x7A)) // 3-byte char, third byte starts with 0 bit
testDecoding(true, "\u1FFF", bytes(0xE1, 0xBF, 0xBF)) // 3-byte char
testOnNonJvm6And7 {
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xAF, 0xBF)) // 3-byte high-surrogate char
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xB3, 0x9A)) // 3-byte low-surrogate char
testDecoding(
false,
surrogateCodePointDecoding + surrogateCodePointDecoding,
bytes(0xED, 0xAF, 0xBF, /**/ 0xED, 0xB3, 0x9A)
) // surrogate pair chars
testDecoding(false, "z", bytes(0xEF, 0x7A)) // 3-byte char, second byte starts with 0 bit, third byte missing
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xAF, 0xBF)) // 3-byte high-surrogate char
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xB3, 0x9A)) // 3-byte low-surrogate char
testDecoding(
false,
surrogateCodePointDecoding + surrogateCodePointDecoding,
bytes(0xED, 0xAF, 0xBF, /**/ 0xED, 0xB3, 0x9A)
) // surrogate pair chars
testDecoding(false, "z", bytes(0xEF, 0x7A)) // 3-byte char, second byte starts with 0 bit, third byte missing
testDecoding(false, "", bytes(0xF9, 0x94, 0x80, 0x80, 0x80)) // 5-byte code point larger than 0x10FFFF
testDecoding(false, "", bytes(0xFD, 0x94, 0x80, 0x80, 0x80, 0x80)) // 6-byte code point larger than 0x10FFFF
testDecoding(false, "", bytes(0xF9, 0x94, 0x80, 0x80, 0x80)) // 5-byte code point larger than 0x10FFFF
testDecoding(false, "", bytes(0xFD, 0x94, 0x80, 0x80, 0x80, 0x80)) // 6-byte code point larger than 0x10FFFF
// Ill-Formed Sequences for Surrogates
testDecoding(
false,
surrogateCodePointDecoding + surrogateCodePointDecoding + truncatedSurrogateDecoding() + "A",
bytes(0xED, 0xA0, 0x80, /**/ 0xED, 0xBF, 0xBF, /**/ 0xED, 0xAF, /**/ 0x41)
)
// Truncated Sequences
testDecoding(false, "A", bytes(0xE1, 0x80, /**/ 0xE2, /**/ 0xF0, 0x91, 0x92, /**/ 0xF1, 0xBF, /**/ 0x41))
}
// Ill-Formed Sequences for Surrogates
testDecoding(
false,
surrogateCodePointDecoding + surrogateCodePointDecoding + truncatedSurrogateDecoding() + "A",
bytes(0xED, 0xA0, 0x80, /**/ 0xED, 0xBF, 0xBF, /**/ 0xED, 0xAF, /**/ 0x41)
)
// Truncated Sequences
testDecoding(false, "A", bytes(0xE1, 0x80, /**/ 0xE2, /**/ 0xF0, 0x91, 0x92, /**/ 0xF1, 0xBF, /**/ 0x41))
testDecoding(false, "", bytes(0xE0, 0xAF)) // 3-byte char, third byte missing
@@ -275,13 +272,11 @@ class StringEncodingTest {
testDecoding(false, "z", bytes(0xEF, 0xAF, 0x7A), startIndex = 1, endIndex = 3)
testDecoding(true, "z", bytes(0xEF, 0xAF, 0x7A), startIndex = 2, endIndex = 3)
testOnNonJvm6And7 {
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xAF, 0xBF), startIndex = 0, endIndex = 3)
testDecoding(false, truncatedSurrogateDecoding(), bytes(0xED, 0xB3, 0x9A), startIndex = 0, endIndex = 2)
testDecoding(false, "", bytes(0xED, 0xAF, 0xBF, 0xED, 0xB3, 0x9A), startIndex = 1, endIndex = 4)
testDecoding(false, "", bytes(0xEF, 0x7A), startIndex = 0, endIndex = 1)
testDecoding(true, "z", bytes(0xEF, 0x7A), startIndex = 1, endIndex = 2)
}
testDecoding(false, surrogateCodePointDecoding, bytes(0xED, 0xAF, 0xBF), startIndex = 0, endIndex = 3)
testDecoding(false, truncatedSurrogateDecoding(), bytes(0xED, 0xB3, 0x9A), startIndex = 0, endIndex = 2)
testDecoding(false, "", bytes(0xED, 0xAF, 0xBF, 0xED, 0xB3, 0x9A), startIndex = 1, endIndex = 4)
testDecoding(false, "", bytes(0xEF, 0x7A), startIndex = 0, endIndex = 1)
testDecoding(true, "z", bytes(0xEF, 0x7A), startIndex = 1, endIndex = 2)
testDecoding(true, "\uD83D\uDFDF", bytes(0xF0, 0x9F, 0x9F, 0x9F), startIndex = 0, endIndex = 4)
testDecoding(false, "", bytes(0xF0, 0x9F, 0x9F, 0x9F), startIndex = 2, endIndex = 4)