99
1010final class ContextUtilityTests {
1111
12- @ ParameterizedTest
13- @ MethodSource ("contextArgs" )
14- final void testContexts (final String expected , final String input , final boolean leading , final boolean trailing ){
15- Assertions .assertEquals (expected , ContextUtility .getContext (input , leading , trailing ));
16- }
12+ @ ParameterizedTest
13+ @ MethodSource ("contextArgs" )
14+ final void testContexts (final String expected , final String input , final boolean leading , final boolean trailing ){
15+ Assertions .assertEquals (expected , ContextUtility .getContext (input , leading , trailing ));
16+ }
1717
18- static Stream <Arguments > contextArgs (){
19- return Stream .of (
20- Arguments .of ("" , "/" , false , false ),
21- Arguments .of ("/" , "" , true , false ),
22- Arguments .of ("/" , "" , false , true ),
23- Arguments .of ("/" , "" , true , true ),
24- Arguments .of ("a" , "a" , false , false ),
25- Arguments .of ("/a" , "a" , true , false ),
26- Arguments .of ("a/" , "a" , false , true ),
27- Arguments .of ("/a/" , "a" , true , true ),
28- Arguments .of ("testNone" , "/testNone/" , false , false ),
29- Arguments .of ("/testLeading" , "testLeading" , true , false ),
30- Arguments .of ("testTrailing/" , "testTrailing" , false , true ),
31- Arguments .of ("/testBoth/" , "testBoth" , true , true ),
32- Arguments .of ("testNoneBackSlash" , "\\ testNoneBackSlash\\ " , false , false ),
33- Arguments .of ("/testBackSlash/" , "\\ testBackSlash\\ " , true , true ),
34- Arguments .of ("/testConsecutiveBackSlash/" , "\\ \\ testConsecutiveBackSlash\\ \\ " , true , true ),
35- Arguments .of ("/testConsecutiveForwardSlash/" , "//testConsecutiveForwardSlash//" , true , true ),
36- Arguments .of ("/testWhitespace/" , " /testWhitespace/ " , true , true ),
37- Arguments .of ("/ testWhitespace /" , "/ testWhitespace /" , true , true ),
38- Arguments .of (" testWhitespace " , "/ testWhitespace /" , false , false ),
39- Arguments .of ("testWhitespace" , " testWhitespace " , false , false ),
40- Arguments .of ("/testWhitespace/" , " /testWhitespace/ " , true , true )
41- );
42- }
18+ static Stream <Arguments > contextArgs (){
19+ return Stream .of (
20+ Arguments .of ("" , "/" , false , false ),
21+ Arguments .of ("/" , "" , true , false ),
22+ Arguments .of ("/" , "" , false , true ),
23+ Arguments .of ("/" , "" , true , true ),
24+ Arguments .of ("a" , "a" , false , false ),
25+ Arguments .of ("/a" , "a" , true , false ),
26+ Arguments .of ("a/" , "a" , false , true ),
27+ Arguments .of ("/a/" , "a" , true , true ),
28+ Arguments .of ("testNone" , "/testNone/" , false , false ),
29+ Arguments .of ("/testLeading" , "testLeading" , true , false ),
30+ Arguments .of ("testTrailing/" , "testTrailing" , false , true ),
31+ Arguments .of ("/testBoth/" , "testBoth" , true , true ),
32+ Arguments .of ("testNoneBackSlash" , "\\ testNoneBackSlash\\ " , false , false ),
33+ Arguments .of ("/testBackSlash/" , "\\ testBackSlash\\ " , true , true ),
34+ Arguments .of ("/testConsecutiveBackSlash/" , "\\ \\ testConsecutiveBackSlash\\ \\ " , true , true ),
35+ Arguments .of ("/testConsecutiveForwardSlash/" , "//testConsecutiveForwardSlash//" , true , true ),
36+ Arguments .of ("/testWhitespace/" , " /testWhitespace/ " , true , true ),
37+ Arguments .of ("/ testWhitespace /" , "/ testWhitespace /" , true , true ),
38+ Arguments .of (" testWhitespace " , "/ testWhitespace /" , false , false ),
39+ Arguments .of ("testWhitespace" , " testWhitespace " , false , false ),
40+ Arguments .of ("/testWhitespace/" , " /testWhitespace/ " , true , true )
41+ );
42+ }
4343
44- @ ParameterizedTest
45- @ MethodSource ("joinArgs" )
46- final void testJoin (final String expected , final boolean leading , final boolean trailing , final String input , final String join ){
47- Assertions .assertEquals (expected , ContextUtility .joinContexts (leading , trailing , input , join ));
48- }
44+ @ ParameterizedTest
45+ @ MethodSource ("joinArgs" )
46+ final void testJoin (final String expected , final boolean leading , final boolean trailing , final String input , final String join ){
47+ Assertions .assertEquals (expected , ContextUtility .joinContexts (leading , trailing , input , join ));
48+ }
4949
50- static Stream <Arguments > joinArgs (){
51- return Stream .of (
52- Arguments .of ("testBlank" , false , false , "testBlank" , "" ),
53- Arguments .of ("/testBlank/" , true , true , "testBlank" , "" ),
54- Arguments .of ("testBlank" , false , false , "" , "testBlank" ),
55- Arguments .of ("/testBlank/" , true , true , "" , "testBlank" ),
56- Arguments .of ("" , false , false , "" , "" ),
57- Arguments .of ("/" , true , true , "" , "" ),
58- Arguments .of ("trailing/slash" , false , false , "trailing/" , "slash/" ),
59- Arguments .of ("/trailing/slash/" , true , true , "trailing/" , "slash/" ),
60- Arguments .of ("leading/slash" , false , false , "leading/" , "slash/" ),
61- Arguments .of ("/leading/slash/" , true , true , "leading/" , "slash/" ),
62- Arguments .of ("double/slash" , false , false , "/double/" , "/slash/" ),
63- Arguments .of ("/double/slash/" , true , true , "/double/" , "/slash/" ),
64- Arguments .of ("no/slash" , false , false , "no" , "slash" ),
65- Arguments .of ("/no/slash/" , true , true , "no" , "slash" ),
66- Arguments .of ("consecutive/slash" , false , false , "//consecutive//" , "//slash//" ),
67- Arguments .of ("/consecutive/slash/" , true , true , "//consecutive//" , "//slash//" ),
68- Arguments .of ("mixed/slash" , false , false , "\\ mixed\\ " , "//slash//" ),
69- Arguments .of ("/mixed/slash/" , true , true , "\\ mixed\\ " , "//slash//" )
70- );
71- }
50+ static Stream <Arguments > joinArgs (){
51+ return Stream .of (
52+ Arguments .of ("testBlank" , false , false , "testBlank" , "" ),
53+ Arguments .of ("/testBlank/" , true , true , "testBlank" , "" ),
54+ Arguments .of ("testBlank" , false , false , "" , "testBlank" ),
55+ Arguments .of ("/testBlank/" , true , true , "" , "testBlank" ),
56+ Arguments .of ("" , false , false , "" , "" ),
57+ Arguments .of ("/" , true , true , "" , "" ),
58+ Arguments .of ("trailing/slash" , false , false , "trailing/" , "slash/" ),
59+ Arguments .of ("/trailing/slash/" , true , true , "trailing/" , "slash/" ),
60+ Arguments .of ("leading/slash" , false , false , "leading/" , "slash/" ),
61+ Arguments .of ("/leading/slash/" , true , true , "leading/" , "slash/" ),
62+ Arguments .of ("double/slash" , false , false , "/double/" , "/slash/" ),
63+ Arguments .of ("/double/slash/" , true , true , "/double/" , "/slash/" ),
64+ Arguments .of ("no/slash" , false , false , "no" , "slash" ),
65+ Arguments .of ("/no/slash/" , true , true , "no" , "slash" ),
66+ Arguments .of ("consecutive/slash" , false , false , "//consecutive//" , "//slash//" ),
67+ Arguments .of ("/consecutive/slash/" , true , true , "//consecutive//" , "//slash//" ),
68+ Arguments .of ("mixed/slash" , false , false , "\\ mixed\\ " , "//slash//" ),
69+ Arguments .of ("/mixed/slash/" , true , true , "\\ mixed\\ " , "//slash//" )
70+ );
71+ }
7272
7373}
0 commit comments