aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src/file_set
diff options
context:
space:
mode:
authorDaiki Ihara <[email protected]>2020-11-30 15:10:12 +0000
committerDaiki Ihara <[email protected]>2020-11-30 15:10:12 +0000
commit59bd6e2eea151f097a65f2634dc5488b3c272d92 (patch)
tree647c3f191e7425791bf828387d5d3ce6f98b0cac /crates/vfs/src/file_set
parentc8a2ff6ecc8e45c7e1420e01d52c8b7a315140e6 (diff)
Extract tests module to file in vfs crate
Diffstat (limited to 'crates/vfs/src/file_set')
-rw-r--r--crates/vfs/src/file_set/tests.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/crates/vfs/src/file_set/tests.rs b/crates/vfs/src/file_set/tests.rs
new file mode 100644
index 000000000..2146df185
--- /dev/null
+++ b/crates/vfs/src/file_set/tests.rs
@@ -0,0 +1,42 @@
1use super::*;
2
3#[test]
4fn path_prefix() {
5 let mut file_set = FileSetConfig::builder();
6 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo".into())]);
7 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo/bar/baz".into())]);
8 let file_set = file_set.build();
9
10 let mut vfs = Vfs::default();
11 vfs.set_file_contents(VfsPath::new_virtual_path("/foo/src/lib.rs".into()), Some(Vec::new()));
12 vfs.set_file_contents(
13 VfsPath::new_virtual_path("/foo/src/bar/baz/lib.rs".into()),
14 Some(Vec::new()),
15 );
16 vfs.set_file_contents(
17 VfsPath::new_virtual_path("/foo/bar/baz/lib.rs".into()),
18 Some(Vec::new()),
19 );
20 vfs.set_file_contents(VfsPath::new_virtual_path("/quux/lib.rs".into()), Some(Vec::new()));
21
22 let partition = file_set.partition(&vfs).into_iter().map(|it| it.len()).collect::<Vec<_>>();
23 assert_eq!(partition, vec![2, 1, 1]);
24}
25
26#[test]
27fn name_prefix() {
28 let mut file_set = FileSetConfig::builder();
29 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo".into())]);
30 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo-things".into())]);
31 let file_set = file_set.build();
32
33 let mut vfs = Vfs::default();
34 vfs.set_file_contents(VfsPath::new_virtual_path("/foo/src/lib.rs".into()), Some(Vec::new()));
35 vfs.set_file_contents(
36 VfsPath::new_virtual_path("/foo-things/src/lib.rs".into()),
37 Some(Vec::new()),
38 );
39
40 let partition = file_set.partition(&vfs).into_iter().map(|it| it.len()).collect::<Vec<_>>();
41 assert_eq!(partition, vec![1, 1, 0]);
42}