aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src/file_set/tests.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-02 12:34:19 +0000
committerGitHub <[email protected]>2020-12-02 12:34:19 +0000
commita8f04712d6a36c5ce870135767d92203a1b2c8ad (patch)
tree2561704ac02e601addd577e39fa5d724ab380c54 /crates/vfs/src/file_set/tests.rs
parent14086e311853d2c40f50102821ff6355c828d0e3 (diff)
parent59bd6e2eea151f097a65f2634dc5488b3c272d92 (diff)
Merge #6679
6679: Extract tests module to file in vfs crate r=matklad a=sasurau4 Helps with #6522 - [x] passed `cargo test` Co-authored-by: Daiki Ihara <[email protected]>
Diffstat (limited to 'crates/vfs/src/file_set/tests.rs')
-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}