+
+ private static boolean testCommonPrefix() {
+ final List<String> l0 = new ArrayList<>();
+ l0.add( "abc" );
+ if ( !ForesterUtil.greatestCommonPrefix( l0 ).equals( "abc" ) ) {
+ return false;
+ }
+ final List<String> l1 = new ArrayList<>();
+ l1.add( "abc" );
+ l1.add( "abX" );
+ if ( !ForesterUtil.greatestCommonPrefix( l1 ).equals( "ab" ) ) {
+ return false;
+ }
+ final List<String> l2 = new ArrayList<>();
+ l2.add( "abc" );
+ l2.add( "abX" );
+ l2.add( "axy" );
+ if ( !ForesterUtil.greatestCommonPrefix( l2 ).equals( "a" ) ) {
+ return false;
+ }
+ final List<String> l3 = new ArrayList<>();
+ l3.add( "abXsdfsdfsdfsdfsdfsd" );
+ l3.add( "abXsdfsdfsdfsdfsdfsd" );
+ l3.add( "abc" );
+ l3.add( "abXsdfsdfsdfsdfsdfsd" );
+ l3.add( "ab" );
+ l3.add( "abc" );
+ l3.add( "ab" );
+ if ( !ForesterUtil.greatestCommonPrefix( l3 ).equals( "ab" ) ) {
+ return false;
+ }
+ final List<String> l4 = new ArrayList<>();
+ l4.add( "abXsdfsdfsdfsdfsdfsd" );
+ l4.add( "abXsdfsdfsdfsdfsdfsd" );
+ l4.add( "abc" );
+ l4.add( "Xsdfsdfsdfsdfsdfsd" );
+ l4.add( "ab" );
+ l4.add( "abc" );
+ if ( !ForesterUtil.greatestCommonPrefix( l4 ).equals( "" ) ) {
+ return false;
+ }
+ final List<String> l5 = new ArrayList<>();
+ l5.add( "" );
+ if ( !ForesterUtil.greatestCommonPrefix( l5 ).equals( "" ) ) {
+ return false;
+ }
+ final List<String> l6 = new ArrayList<>();
+ l6.add( "abc" );
+ l6.add( "abX" );
+ l6.add( "" );
+ if ( !ForesterUtil.greatestCommonPrefix( l6 ).equals( "" ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testCommonPrefixSep() {
+ final List<String> l0 = new ArrayList<>();
+ l0.add( "a.b.c" );
+ if ( !ForesterUtil.greatestCommonPrefix( l0, "." ).equals( "a.b.c" ) ) {
+ return false;
+ }
+ final List<String> l1 = new ArrayList<>();
+ l1.add( "a.b.c" );
+ l1.add( "a.b.X" );
+ if ( !ForesterUtil.greatestCommonPrefix( l1, "." ).equals( "a.b" ) ) {
+ return false;
+ }
+ final List<String> l2 = new ArrayList<>();
+ l2.add( "a.b.c." );
+ l2.add( "a.b.X." );
+ l2.add( "a.x.y." );
+ if ( !ForesterUtil.greatestCommonPrefix( l2, "." ).equals( "a" ) ) {
+ return false;
+ }
+ final List<String> l3 = new ArrayList<>();
+ l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d/" );
+ l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d" );
+ l3.add( "a/b/c" );
+ l3.add( "a/b/X/s/d/f/s/d/f/s/d/f/s/d/f/s/d/f/s/d/" );
+ l3.add( "a/b/" );
+ l3.add( "a/b/c/" );
+ l3.add( "a/b////////" );
+ if ( !ForesterUtil.greatestCommonPrefix( l3, "/" ).equals( "a/b" ) ) {
+ return false;
+ }
+ final List<String> l4 = new ArrayList<>();
+ l4.add( "a.b.X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d" );
+ l4.add( "a.b.X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d" );
+ l4.add( "a.b.c" );
+ l4.add( "X.s.d.f.s.d.f.s.d.f.s.d.f.s.d.f.s.d..." );
+ l4.add( "a.b" );
+ l4.add( "a.b.c" );
+ if ( !ForesterUtil.greatestCommonPrefix( l4, "." ).equals( "" ) ) {
+ return false;
+ }
+ final List<String> l5 = new ArrayList<>();
+ l5.add( "" );
+ if ( !ForesterUtil.greatestCommonPrefix( l5, "_" ).equals( "" ) ) {
+ return false;
+ }
+ final List<String> l6 = new ArrayList<>();
+ l6.add( "_" );
+ l6.add( "__" );
+ if ( !ForesterUtil.greatestCommonPrefix( l6, "_" ).equals( "" ) ) {
+ return false;
+ }
+ final List<String> l7 = new ArrayList<>();
+ l7.add( "a,b,c" );
+ l7.add( "a,b,X" );
+ l7.add( "" );
+ l7.add( ",,,,,,,,,," );
+ if ( !ForesterUtil.greatestCommonPrefix( l7, "," ).equals( "" ) ) {
+ return false;
+ }
+ final List<String> l8 = new ArrayList<>();
+ l8.add( "123.304.403.04" );
+ l8.add( "123.304.403.04.02" );
+ l8.add( "123.304.403.03.03" );
+ if ( !ForesterUtil.greatestCommonPrefix( l8, "." ).equals( "123.304.403" ) ) {
+ return false;
+ }
+ final List<String> l9 = new ArrayList<>();
+ l9.add( "123.304.403.04" );
+ l9.add( "123.304.403.04.02" );
+ l9.add( "123.304.402.03.03" );
+ if ( !ForesterUtil.greatestCommonPrefix( l9, "." ).equals( "123.304" ) ) {
+ return false;
+ }
+ final List<String> l10 = new ArrayList<>();
+ l10.add( "abcde" );
+ l10.add( "adc" );
+ if ( !ForesterUtil.greatestCommonPrefix( l10, "." ).equals( "" ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean testContainsPrefix() {
+ if ( !ForesterUtil.isContainsPrefix( "a.b", "a", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( "a.b.c", "a", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( "a.b.c", "a.b", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( "a.b", "a.b", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( "a", "a", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( ".a.b", ".a", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( ".a.b.", ".a", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( ".a.b.", ".a.", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( "a..b.", "a", "." ) ) {
+ return false;
+ }
+ if ( !ForesterUtil.isContainsPrefix( "a..b.", "a..", "." ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isContainsPrefix( "a", "a.b", "." ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isContainsPrefix( "a_b", "a", "." ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isContainsPrefix( ".a.", ".a.b.", "." ) ) {
+ return false;
+ }
+ if ( ForesterUtil.isContainsPrefix( "a.b.c", "a.x", "." ) ) {
+ return false;
+ }
+ return true;
+ }
+