aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src/file_set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/vfs/src/file_set.rs')
-rw-r--r--crates/vfs/src/file_set.rs51
1 files changed, 1 insertions, 50 deletions
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs
index 4aa2d6526..9093fbd97 100644
--- a/crates/vfs/src/file_set.rs
+++ b/crates/vfs/src/file_set.rs
@@ -158,53 +158,4 @@ impl fst::Automaton for PrefixOf<'_> {
158} 158}
159 159
160#[cfg(test)] 160#[cfg(test)]
161mod tests { 161mod tests;
162 use super::*;
163
164 #[test]
165 fn path_prefix() {
166 let mut file_set = FileSetConfig::builder();
167 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo".into())]);
168 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo/bar/baz".into())]);
169 let file_set = file_set.build();
170
171 let mut vfs = Vfs::default();
172 vfs.set_file_contents(
173 VfsPath::new_virtual_path("/foo/src/lib.rs".into()),
174 Some(Vec::new()),
175 );
176 vfs.set_file_contents(
177 VfsPath::new_virtual_path("/foo/src/bar/baz/lib.rs".into()),
178 Some(Vec::new()),
179 );
180 vfs.set_file_contents(
181 VfsPath::new_virtual_path("/foo/bar/baz/lib.rs".into()),
182 Some(Vec::new()),
183 );
184 vfs.set_file_contents(VfsPath::new_virtual_path("/quux/lib.rs".into()), Some(Vec::new()));
185
186 let partition = file_set.partition(&vfs).into_iter().map(|it| it.len()).collect::<Vec<_>>();
187 assert_eq!(partition, vec![2, 1, 1]);
188 }
189
190 #[test]
191 fn name_prefix() {
192 let mut file_set = FileSetConfig::builder();
193 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo".into())]);
194 file_set.add_file_set(vec![VfsPath::new_virtual_path("/foo-things".into())]);
195 let file_set = file_set.build();
196
197 let mut vfs = Vfs::default();
198 vfs.set_file_contents(
199 VfsPath::new_virtual_path("/foo/src/lib.rs".into()),
200 Some(Vec::new()),
201 );
202 vfs.set_file_contents(
203 VfsPath::new_virtual_path("/foo-things/src/lib.rs".into()),
204 Some(Vec::new()),
205 );
206
207 let partition = file_set.partition(&vfs).into_iter().map(|it| it.len()).collect::<Vec<_>>();
208 assert_eq!(partition, vec![1, 1, 0]);
209 }
210}