Commit 6a6cf1b9 authored by Sehny's avatar Sehny
Browse files

Tests for buffer.

parent 9e26f938
...@@ -426,4 +426,42 @@ mod tests { ...@@ -426,4 +426,42 @@ mod tests {
assert_eq!(buf.redo(), true); assert_eq!(buf.redo(), true);
assert_eq!(String::from(buf), "defg"); assert_eq!(String::from(buf), "defg");
} }
#[test]
fn test_is_match() {
let mut buf = Buffer::new();
buf.insert(0, &['a', 'b', 'c', 'd', 'e', 'f', 'g']);
let mut buf2 = Buffer::new();
buf2.insert(0, &['a', 'b', 'c']);
assert_eq!(buf.is_match(&buf2), true);
}
#[test]
fn test_is_not_match() {
let mut buf = Buffer::new();
buf.insert(0, &['a', 'b', 'c']);
let mut buf2 = Buffer::new();
buf2.insert(0, &['a', 'b', 'c']);
assert_eq!(buf.is_match(&buf2), false);
}
#[test]
fn test_is_not_match2() {
let mut buf = Buffer::new();
buf.insert(0, &['a', 'b', 'c', 'd', 'e', 'f', 'g']);
let mut buf2 = Buffer::new();
buf2.insert(0, &['x', 'y', 'z']);
assert_eq!(buf.is_match(&buf2), false);
}
#[test]
fn test_print_rest() {
let mut buf = Buffer::new();
buf.insert(0, &['a', 'b', 'c', 'd', 'e', 'f', 'g']);
let mut buf2 = Buffer::new();
buf2.insert(0, &['a', 'b', 'c']);
let mut out: Vec<u8> = vec![];
buf.print_rest(&mut out, &buf2).unwrap();
assert_eq!(out.len(), 4);
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment