5537: Add one more test r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-07-26 09:05:54 +00:00 committed by GitHub
commit 4e21fc3136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,15 +148,22 @@ fn accept(&self, &state: &usize, byte: u8) -> usize {
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_partitioning() {
fn path_prefix() {
let mut file_set = FileSetConfig::builder();
file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo".into())]);
file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo/bar/baz".into())]);
let file_set = file_set.build();
let mut vfs = Vfs::default();
vfs.set_file_contents(VfsPath::new_virtual_path("/foo/src/lib.rs".into()), Some(Vec::new()));
vfs.set_file_contents(
VfsPath::new_virtual_path("/foo/src/lib.rs".into()),
Some(Vec::new()),
);
vfs.set_file_contents(
VfsPath::new_virtual_path("/foo/src/bar/baz/lib.rs".into()),
Some(Vec::new()),
@ -170,3 +177,25 @@ fn test_partitioning() {
let partition = file_set.partition(&vfs).into_iter().map(|it| it.len()).collect::<Vec<_>>();
assert_eq!(partition, vec![2, 1, 1]);
}
#[test]
fn name_prefix() {
let mut file_set = FileSetConfig::builder();
file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo".into())]);
file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo-things".into())]);
let file_set = file_set.build();
let mut vfs = Vfs::default();
vfs.set_file_contents(
VfsPath::new_virtual_path("/foo/src/lib.rs".into()),
Some(Vec::new()),
);
vfs.set_file_contents(
VfsPath::new_virtual_path("/foo-things/src/lib.rs".into()),
Some(Vec::new()),
);
let partition = file_set.partition(&vfs).into_iter().map(|it| it.len()).collect::<Vec<_>>();
assert_eq!(partition, vec![1, 1, 0]);
}
}