Merge "Fix failing unit tests for android.text.format.Formatter"

This commit is contained in:
TreeHugger Robot
2016-06-30 01:34:52 +00:00
committed by Android (Google) Code Review

View File

@@ -68,23 +68,26 @@ public class FormatterTest extends AndroidTestCase {
checkFormatBytes(123, true, "123", 123);
checkFormatBytes(123, false, "123", 123);
checkFormatBytes(812, true, "812", 812);
checkFormatBytes(812, false, "812", 812);
checkFormatBytes(900, true, "900", 900);
checkFormatBytes(900, false, "900", 900);
checkFormatBytes(912, true, "0.89", 911);
checkFormatBytes(912, false, "0.89", 911);
checkFormatBytes(901, true, "0.90", 900);
checkFormatBytes(901, false, "0.90", 900);
checkFormatBytes(9123, true, "8.9", 9113);
checkFormatBytes(9123, false, "8.91", 9123);
checkFormatBytes(912, true, "0.91", 910);
checkFormatBytes(912, false, "0.91", 910);
checkFormatBytes(9123000, true, "8.7", 9122611);
checkFormatBytes(9123000, false, "8.70", 9122611);
checkFormatBytes(9123, true, "9.1", 9100);
checkFormatBytes(9123, false, "9.12", 9120);
checkFormatBytes(9123456, true, "9.1", 9100000);
checkFormatBytes(9123456, false, "9.12", 9120000);
checkFormatBytes(-1, true, "-1", -1);
checkFormatBytes(-1, false, "-1", -1);
checkFormatBytes(-912, true, "-0.89", -911);
checkFormatBytes(-912, false, "-0.89", -911);
checkFormatBytes(-914, true, "-0.91", -910);
checkFormatBytes(-914, false, "-0.91", -910);
// Missing FLAG_CALCULATE_ROUNDED case.
BytesResult r = Formatter.formatBytes(getContext().getResources(), 1, 0);
@@ -93,7 +96,7 @@ public class FormatterTest extends AndroidTestCase {
// Make sure it works on different locales.
setLocale(new Locale("es", "ES"));
checkFormatBytes(9123000, false, "8,70", 9122611);
checkFormatBytes(9123000, false, "9,12", 9120000);
}
private void checkFormatBytes(long bytes, boolean useShort,