summaryrefslogtreecommitdiffstats
path: root/vendor/bstr/src/tests.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/bstr/src/tests.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/bstr/src/tests.rs')
-rw-r--r--vendor/bstr/src/tests.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/bstr/src/tests.rs b/vendor/bstr/src/tests.rs
new file mode 100644
index 000000000..f4179fd1d
--- /dev/null
+++ b/vendor/bstr/src/tests.rs
@@ -0,0 +1,32 @@
+/// A sequence of tests for checking whether lossy decoding uses the maximal
+/// subpart strategy correctly. Namely, if a sequence of otherwise invalid
+/// UTF-8 bytes is a valid prefix of a valid UTF-8 sequence, then the entire
+/// prefix is replaced by a single replacement codepoint. In all other cases,
+/// each invalid byte is replaced by a single replacement codepoint.
+///
+/// The first element in each tuple is the expected result of lossy decoding,
+/// while the second element is the input given.
+pub const LOSSY_TESTS: &[(&str, &[u8])] = &[
+ ("a", b"a"),
+ ("\u{FFFD}", b"\xFF"),
+ ("\u{FFFD}\u{FFFD}", b"\xFF\xFF"),
+ ("β\u{FFFD}", b"\xCE\xB2\xFF"),
+ ("☃\u{FFFD}", b"\xE2\x98\x83\xFF"),
+ ("𝝱\u{FFFD}", b"\xF0\x9D\x9D\xB1\xFF"),
+ ("\u{FFFD}\u{FFFD}", b"\xCE\xF0"),
+ ("\u{FFFD}\u{FFFD}", b"\xCE\xFF"),
+ ("\u{FFFD}\u{FFFD}", b"\xE2\x98\xF0"),
+ ("\u{FFFD}\u{FFFD}", b"\xE2\x98\xFF"),
+ ("\u{FFFD}", b"\xF0\x9D\x9D"),
+ ("\u{FFFD}\u{FFFD}", b"\xF0\x9D\x9D\xF0"),
+ ("\u{FFFD}\u{FFFD}", b"\xF0\x9D\x9D\xFF"),
+ ("\u{FFFD}", b"\xCE"),
+ ("a\u{FFFD}", b"a\xCE"),
+ ("\u{FFFD}", b"\xE2\x98"),
+ ("a\u{FFFD}", b"a\xE2\x98"),
+ ("\u{FFFD}", b"\xF0\x9D\x9C"),
+ ("a\u{FFFD}", b"a\xF0\x9D\x9C"),
+ ("a\u{FFFD}\u{FFFD}\u{FFFD}z", b"a\xED\xA0\x80z"),
+ ("☃βツ\u{FFFD}", b"\xe2\x98\x83\xce\xb2\xe3\x83\x84\xFF"),
+ ("a\u{FFFD}\u{FFFD}\u{FFFD}b", b"\x61\xF1\x80\x80\xE1\x80\xC2\x62"),
+];