@@ -148,25 +148,54 @@ impl fst::Automaton for PrefixOf<'_> {
148148 }
149149}
150150
151- #[ test]
152- fn test_partitioning ( ) {
153- let mut file_set = FileSetConfig :: builder ( ) ;
154- file_set. add_file_set ( vec ! [ VfsPath :: new_virtual_path( "/foo" . into( ) ) ] ) ;
155- file_set. add_file_set ( vec ! [ VfsPath :: new_virtual_path( "/foo/bar/baz" . into( ) ) ] ) ;
156- let file_set = file_set. build ( ) ;
157-
158- let mut vfs = Vfs :: default ( ) ;
159- vfs. set_file_contents ( VfsPath :: new_virtual_path ( "/foo/src/lib.rs" . into ( ) ) , Some ( Vec :: new ( ) ) ) ;
160- vfs. set_file_contents (
161- VfsPath :: new_virtual_path ( "/foo/src/bar/baz/lib.rs" . into ( ) ) ,
162- Some ( Vec :: new ( ) ) ,
163- ) ;
164- vfs. set_file_contents (
165- VfsPath :: new_virtual_path ( "/foo/bar/baz/lib.rs" . into ( ) ) ,
166- Some ( Vec :: new ( ) ) ,
167- ) ;
168- vfs. set_file_contents ( VfsPath :: new_virtual_path ( "/quux/lib.rs" . into ( ) ) , Some ( Vec :: new ( ) ) ) ;
169-
170- let partition = file_set. partition ( & vfs) . into_iter ( ) . map ( |it| it. len ( ) ) . collect :: < Vec < _ > > ( ) ;
171- assert_eq ! ( partition, vec![ 2 , 1 , 1 ] ) ;
151+ #[ cfg( test) ]
152+ mod tests {
153+ use super :: * ;
154+
155+ #[ test]
156+ fn path_prefix ( ) {
157+ let mut file_set = FileSetConfig :: builder ( ) ;
158+ file_set. add_file_set ( vec ! [ VfsPath :: new_virtual_path( "/foo" . into( ) ) ] ) ;
159+ file_set. add_file_set ( vec ! [ VfsPath :: new_virtual_path( "/foo/bar/baz" . into( ) ) ] ) ;
160+ let file_set = file_set. build ( ) ;
161+
162+ let mut vfs = Vfs :: default ( ) ;
163+ vfs. set_file_contents (
164+ VfsPath :: new_virtual_path ( "/foo/src/lib.rs" . into ( ) ) ,
165+ Some ( Vec :: new ( ) ) ,
166+ ) ;
167+ vfs. set_file_contents (
168+ VfsPath :: new_virtual_path ( "/foo/src/bar/baz/lib.rs" . into ( ) ) ,
169+ Some ( Vec :: new ( ) ) ,
170+ ) ;
171+ vfs. set_file_contents (
172+ VfsPath :: new_virtual_path ( "/foo/bar/baz/lib.rs" . into ( ) ) ,
173+ Some ( Vec :: new ( ) ) ,
174+ ) ;
175+ vfs. set_file_contents ( VfsPath :: new_virtual_path ( "/quux/lib.rs" . into ( ) ) , Some ( Vec :: new ( ) ) ) ;
176+
177+ let partition = file_set. partition ( & vfs) . into_iter ( ) . map ( |it| it. len ( ) ) . collect :: < Vec < _ > > ( ) ;
178+ assert_eq ! ( partition, vec![ 2 , 1 , 1 ] ) ;
179+ }
180+
181+ #[ test]
182+ fn name_prefix ( ) {
183+ let mut file_set = FileSetConfig :: builder ( ) ;
184+ file_set. add_file_set ( vec ! [ VfsPath :: new_virtual_path( "/foo" . into( ) ) ] ) ;
185+ file_set. add_file_set ( vec ! [ VfsPath :: new_virtual_path( "/foo-things" . into( ) ) ] ) ;
186+ let file_set = file_set. build ( ) ;
187+
188+ let mut vfs = Vfs :: default ( ) ;
189+ vfs. set_file_contents (
190+ VfsPath :: new_virtual_path ( "/foo/src/lib.rs" . into ( ) ) ,
191+ Some ( Vec :: new ( ) ) ,
192+ ) ;
193+ vfs. set_file_contents (
194+ VfsPath :: new_virtual_path ( "/foo-things/src/lib.rs" . into ( ) ) ,
195+ Some ( Vec :: new ( ) ) ,
196+ ) ;
197+
198+ let partition = file_set. partition ( & vfs) . into_iter ( ) . map ( |it| it. len ( ) ) . collect :: < Vec < _ > > ( ) ;
199+ assert_eq ! ( partition, vec![ 1 , 1 , 0 ] ) ;
200+ }
172201}
0 commit comments