better report failing plurals tests
This commit is contained in:
parent
53a17e6146
commit
bb47d1e41e
@ -99,13 +99,14 @@ public class LocalizationTest {
|
|||||||
// Resources() requires DisplayMetrics, but they are only needed for drawables
|
// Resources() requires DisplayMetrics, but they are only needed for drawables
|
||||||
resources = new Resources(assets, new DisplayMetrics(), config);
|
resources = new Resources(assets, new DisplayMetrics(), config);
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
|
String formats = null;
|
||||||
|
try {
|
||||||
int resId = field.getInt(int.class);
|
int resId = field.getInt(int.class);
|
||||||
for (int quantity = 0; quantity < 22; quantity++) {
|
for (int quantity = 0; quantity < 22; quantity++) {
|
||||||
resources.getQuantityString(resId, quantity);
|
resources.getQuantityString(resId, quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
String formats = haveFormats.get(field.getName());
|
formats = haveFormats.get(field.getName());
|
||||||
try {
|
|
||||||
switch (formats) {
|
switch (formats) {
|
||||||
case "d":
|
case "d":
|
||||||
resources.getQuantityString(resId, 1, 1);
|
resources.getQuantityString(resId, 1, 1);
|
||||||
@ -121,7 +122,7 @@ public class LocalizationTest {
|
|||||||
throw new IllegalStateException("Pattern not included in tests: " + formats);
|
throw new IllegalStateException("Pattern not included in tests: " + formats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalFormatException e) {
|
} catch (IllegalFormatException | Resources.NotFoundException e) {
|
||||||
Log.i(TAG, locale + " " + field.getName());
|
Log.i(TAG, locale + " " + field.getName());
|
||||||
throw new IllegalArgumentException("Bad '" + formats + "' format in " + locale + " "
|
throw new IllegalArgumentException("Bad '" + formats + "' format in " + locale + " "
|
||||||
+ field.getName() + ": " + e.getMessage());
|
+ field.getName() + ": " + e.getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user