File: test.rs

package info (click to toggle)
rust-dissimilar 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 232 kB
  • sloc: makefile: 4
file content (19 lines) | stat: -rw-r--r-- 696 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 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.

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)]);
}