|
@@ -6,8 +6,7 @@ |
6 |
6 |
|
|
7 |
7 |
|
import java.util.*; |
8 |
8 |
|
|
9 |
|
- |
public class DerivedLocaleGraphTest |
10 |
|
- |
{ |
|
9 |
+ |
public class DerivedLocaleGraphTest { |
11 |
10 |
|
private static final List<String> FRENCH_CANADIAN = toCodes( Locale.CANADA_FRENCH, Locale.FRENCH, Locale.CANADA, Locale.ENGLISH ); |
12 |
11 |
|
private static final List<String> ENGLISH_CANADIAN = toCodes( Locale.CANADA, Locale.ENGLISH ); |
13 |
12 |
|
private static final List<String> ENGLISH_US = toCodes( Locale.US, Locale.ENGLISH ); |
|
@@ -34,8 +33,7 @@ |
34 |
33 |
|
|
35 |
34 |
|
@Test |
36 |
35 |
|
public void testSelect() |
37 |
|
- |
throws Exception |
38 |
|
- |
{ |
|
36 |
+ |
throws Exception { |
39 |
37 |
|
expectSelected( Locale_fr_FR.INSTANCE, FRENCH_CANADIAN, null, SUPPORTED ); |
40 |
38 |
|
expectSelected( Locale_fr_CA.INSTANCE, FRENCH_CANADIAN, Locale_fr_CA.INSTANCE, SUPPORTED ); |
41 |
39 |
|
expectSelected( Locale_en_CA.INSTANCE, FRENCH_CANADIAN, Locale_en_CA.INSTANCE, Locale_en_US.INSTANCE ); |
|
@@ -93,16 +91,13 @@ |
93 |
91 |
|
expectSelected( Locale_en_US.INSTANCE, zTonga, Locale_en_GB.INSTANCE, Locale_en_US.INSTANCE ); |
94 |
92 |
|
} |
95 |
93 |
|
|
96 |
|
- |
private void expectSelected( AbstractLocale pExpected, List<String> pLocaleCodesToTest, AbstractLocale pAdditionalSupported, AbstractLocale... pSupported ) |
97 |
|
- |
{ |
|
94 |
+ |
private void expectSelected( AbstractLocale pExpected, List<String> pLocaleCodesToTest, AbstractLocale pAdditionalSupported, AbstractLocale... pSupported ) { |
98 |
95 |
|
Set<AbstractLocale> zSupported = Locales.toSet( pSupported ); |
99 |
|
- |
if ( pAdditionalSupported != null ) |
100 |
|
- |
{ |
|
96 |
+ |
if ( pAdditionalSupported != null ) { |
101 |
97 |
|
zSupported.add( pAdditionalSupported ); |
102 |
98 |
|
} |
103 |
99 |
|
AbstractLocale zSelected = DerivedLocaleGraph.select( zSupported, pLocaleCodesToTest ); |
104 |
|
- |
if ( !pExpected.equals( zSelected ) ) |
105 |
|
- |
{ |
|
100 |
+ |
if ( !pExpected.equals( zSelected ) ) { |
106 |
101 |
|
throw new AssertionFailedError( "\n" |
107 |
102 |
|
+ "Expected: " + pExpected + "\n" |
108 |
103 |
|
+ " Actual: " + zSelected + "\n" |
|
@@ -112,11 +107,9 @@ |
112 |
107 |
|
} |
113 |
108 |
|
} |
114 |
109 |
|
|
115 |
|
- |
private static List<String> toCodes( Locale... pLocales ) |
116 |
|
- |
{ |
|
110 |
+ |
private static List<String> toCodes( Locale... pLocales ) { |
117 |
111 |
|
List<String> zCodes = new ArrayList<>( pLocales.length ); |
118 |
|
- |
for ( Locale zLocale : pLocales ) |
119 |
|
- |
{ |
|
112 |
+ |
for ( Locale zLocale : pLocales ) { |
120 |
113 |
|
zCodes.add( AbstractLocale.toCode( zLocale.getLanguage(), zLocale.getCountry() ) ); |
121 |
114 |
|
} |
122 |
115 |
|
return Collections.unmodifiableList( zCodes ); |