summaryrefslogtreecommitdiffstats
path: root/vendor/dissimilar/tests
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/dissimilar/tests
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/dissimilar/tests')
-rw-r--r--vendor/dissimilar/tests/test.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/dissimilar/tests/test.rs b/vendor/dissimilar/tests/test.rs
new file mode 100644
index 000000000..e68fd4f11
--- /dev/null
+++ b/vendor/dissimilar/tests/test.rs
@@ -0,0 +1,40 @@
+// Upstream diff-match-patch's test suite is imported as unit tests in
+// src/tests.rs, as they test APIs which are private in the Rust implementation.
+//
+// This directory is for Rust-specific integration tests and regression tests.
+
+#![allow(clippy::non_ascii_literal)]
+
+use dissimilar::{diff, Chunk};
+
+#[test]
+fn test_unicode() {
+ // Unicode snowman and unicode comet have the same first two bytes. A
+ // byte-based diff would produce a 2-byte Equal followed by 1-byte Delete
+ // and Insert.
+ let snowman = "\u{2603}";
+ let comet = "\u{2604}";
+ assert_eq!(snowman.as_bytes()[..2], comet.as_bytes()[..2]);
+
+ let d = diff(snowman, comet);
+ assert_eq!(d, vec![Chunk::Delete(snowman), Chunk::Insert(comet)]);
+}
+
+#[test]
+fn test_unicode2() {
+ let a = "[乀丁abcd一]";
+ let b = "[一abcd丁]";
+ let d = diff(a, b);
+ assert_eq!(
+ d,
+ vec![
+ Chunk::Equal("["),
+ Chunk::Delete("乀丁"),
+ Chunk::Insert("一"),
+ Chunk::Equal("abcd"),
+ Chunk::Delete("一"),
+ Chunk::Insert("丁"),
+ Chunk::Equal("]"),
+ ]
+ );
+}