@@ -12,101 +12,64 @@ class ChildLimitStaticTest {
1212 @ TempDir
1313 private Path root ;
1414
15- private FileTreePrettyPrinter printer = FileTreePrettyPrinter .builder ()
16- .customizeOptions (options -> options .withChildLimit (3 ))
17- .build ();
18-
1915 @ Test
20- void nominal () {
16+ void empty_directory () {
2117 var path = FileStructures .emptyDirectory (root );
18+ var printer = FileTreePrettyPrinter .builder ()
19+ .customizeOptions (options -> options .withChildLimit (3 ))
20+ .build ();
2221 var result = printer .prettyPrint (path );
2322 var expected = "targetPath/" ;
2423 assertThat (result ).isEqualTo (expected );
2524 }
2625
27- @ Test
28- void dirWith_1_file () {
29- var path = FileStructures .simpleDirectoryWithFiles (root , 1 );
30- var result = printer .prettyPrint (path );
31- var expected = """
32- targetPath/
33- └─ file1""" ;
34- assertThat (result ).isEqualTo (expected );
35- }
26+ private void doTest (int limit , String expected ) {
27+ var path = FileStructures .simpleDirectoryWithFiles (root , 3 );
3628
37- @ Test
38- void dirWith_limit_minus_one_files () {
39- var path = FileStructures .simpleDirectoryWithFiles (root , 2 );
40- var result = printer .prettyPrint (path );
41- var expected = """
42- targetPath/
43- ├─ file1
44- └─ file2""" ;
45- assertThat (result ).isEqualTo (expected );
46- }
29+ var printer = FileTreePrettyPrinter .builder ()
30+ .customizeOptions (options -> options .withChildLimit (limit ))
31+ .build ();
4732
48- @ Test
49- void dirWith_exact_limit_of_files () {
50- var path = FileStructures .simpleDirectoryWithFiles (root , 3 );
5133 var result = printer .prettyPrint (path );
52- var expected = """
53- targetPath/
54- ├─ file1
55- ├─ file2
56- └─ file3""" ;
34+
5735 assertThat (result ).isEqualTo (expected );
5836 }
5937
6038 @ Test
61- void dirWith_1_extra_file () {
62- var path = FileStructures .simpleDirectoryWithFiles (root , 4 );
63- var result = printer .prettyPrint (path );
39+ void test_0_file () {
6440 var expected = """
6541 targetPath/
66- ├─ file1
67- ├─ file2
68- ├─ file3
6942 └─ ...""" ;
70- assertThat ( result ). isEqualTo ( expected );
43+ doTest ( 0 , expected );
7144 }
7245
7346 @ Test
74- void dirWith_2_extra_files () {
75- var path = FileStructures .simpleDirectoryWithFiles (root , 5 );
76- var result = printer .prettyPrint (path );
47+ void test_1_file () {
7748 var expected = """
7849 targetPath/
7950 ├─ file1
80- ├─ file2
81- ├─ file3
8251 └─ ...""" ;
83- assertThat ( result ). isEqualTo ( expected );
52+ doTest ( 1 , expected );
8453 }
8554
8655 @ Test
87- void dirWith_2_extra_files_and_1_extra_folder () {
88- var path = FileStructures .simpleDirectoryWithFilesAndFolders (root , 5 , 1 );
89- var result = printer .prettyPrint (path );
56+ void test_limit_minus_one_files () {
9057 var expected = """
9158 targetPath/
9259 ├─ file1
9360 ├─ file2
94- ├─ file3
9561 └─ ...""" ;
96- assertThat ( result ). isEqualTo ( expected );
62+ doTest ( 2 , expected );
9763 }
9864
9965 @ Test
100- void dirWith_2_extra_files_and_2_extra_folders () {
101- var path = FileStructures .simpleDirectoryWithFilesAndFolders (root , 5 , 2 );
102- var result = printer .prettyPrint (path );
66+ void test_exact_limit_of_files () {
10367 var expected = """
10468 targetPath/
10569 ├─ file1
10670 ├─ file2
107- ├─ file3
108- └─ ...""" ;
109- assertThat (result ).isEqualTo (expected );
71+ └─ file3""" ;
72+ doTest (3 , expected );
11073 }
11174
11275}
0 commit comments