11extern crate difference;
22extern crate file;
33
4- use std:: path:: { PathBuf , Path } ;
4+ use std:: path:: { Path , PathBuf } ;
55use std:: fs:: read_dir;
66
77use difference:: Changeset ;
@@ -21,12 +21,9 @@ fn read_text(path: &Path) -> String {
2121 file:: get_text ( path) . unwrap ( ) . replace ( "\r \n " , "\n " )
2222}
2323
24- pub fn dir_tests < F > (
25- paths : & [ & str ] ,
26- f : F
27- )
24+ pub fn dir_tests < F > ( paths : & [ & str ] , f : F )
2825where
29- F : Fn ( & str ) -> String
26+ F : Fn ( & str ) -> String ,
3027{
3128 for path in collect_tests ( paths) {
3229 let actual = {
@@ -47,21 +44,20 @@ where
4744 }
4845}
4946
50- fn assert_equal_text (
51- expected : & str ,
52- actual : & str ,
53- path : & Path
54- ) {
47+ fn assert_equal_text ( expected : & str , actual : & str , path : & Path ) {
5548 if expected != actual {
5649 print_difference ( expected, actual, path)
5750 }
5851}
5952
6053fn collect_tests ( paths : & [ & str ] ) -> Vec < PathBuf > {
61- paths. iter ( ) . flat_map ( |path| {
62- let path = test_data_dir ( ) . join ( path) ;
63- test_from_dir ( & path) . into_iter ( )
64- } ) . collect ( )
54+ paths
55+ . iter ( )
56+ . flat_map ( |path| {
57+ let path = test_data_dir ( ) . join ( path) ;
58+ test_from_dir ( & path) . into_iter ( )
59+ } )
60+ . collect ( )
6561}
6662
6763fn test_from_dir ( dir : & Path ) -> Vec < PathBuf > {
@@ -95,11 +91,13 @@ fn print_difference(expected: &str, actual: &str, path: &Path) {
9591fn project_dir ( ) -> PathBuf {
9692 let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
9793 PathBuf :: from ( dir)
98- . parent ( ) . unwrap ( )
99- . parent ( ) . unwrap ( )
94+ . parent ( )
95+ . unwrap ( )
96+ . parent ( )
97+ . unwrap ( )
10098 . to_owned ( )
10199}
102100
103101fn test_data_dir ( ) -> PathBuf {
104102 project_dir ( ) . join ( "tests/data" )
105- }
103+ }
0 commit comments