use of android.text.format.Formatter.BytesResult in project android_frameworks_base by DirtyUnicorns.
the class FormatterTest method testFormatBytes.
@SmallTest
public void testFormatBytes() {
setLocale(Locale.ENGLISH);
checkFormatBytes(0, true, "0", 0);
checkFormatBytes(0, false, "0", 0);
checkFormatBytes(1, true, "1", 1);
checkFormatBytes(1, false, "1", 1);
checkFormatBytes(12, true, "12", 12);
checkFormatBytes(12, false, "12", 12);
checkFormatBytes(123, true, "123", 123);
checkFormatBytes(123, false, "123", 123);
checkFormatBytes(812, true, "812", 812);
checkFormatBytes(812, false, "812", 812);
checkFormatBytes(912, true, "0.89", 911);
checkFormatBytes(912, false, "0.89", 911);
checkFormatBytes(9123, true, "8.9", 9113);
checkFormatBytes(9123, false, "8.91", 9123);
checkFormatBytes(9123000, true, "8.7", 9122611);
checkFormatBytes(9123000, false, "8.70", 9122611);
checkFormatBytes(-1, true, "-1", -1);
checkFormatBytes(-1, false, "-1", -1);
checkFormatBytes(-912, true, "-0.89", -911);
checkFormatBytes(-912, false, "-0.89", -911);
// Missing FLAG_CALCULATE_ROUNDED case.
BytesResult r = Formatter.formatBytes(getContext().getResources(), 1, 0);
assertEquals("1", r.value);
// Didn't pass FLAG_CALCULATE_ROUNDED
assertEquals(0, r.roundedBytes);
// Make sure it works on different locales.
setLocale(new Locale("es", "ES"));
checkFormatBytes(9123000, false, "8,70", 9122611);
}
use of android.text.format.Formatter.BytesResult in project android_frameworks_base by crdroidandroid.
the class FormatterTest method checkFormatBytes.
private void checkFormatBytes(long bytes, boolean useShort, String expectedString, long expectedRounded) {
BytesResult r = Formatter.formatBytes(getContext().getResources(), bytes, Formatter.FLAG_CALCULATE_ROUNDED | (useShort ? Formatter.FLAG_SHORTER : 0));
assertEquals(expectedString, r.value);
assertEquals(expectedRounded, r.roundedBytes);
}
use of android.text.format.Formatter.BytesResult in project android_frameworks_base by AOSPA.
the class FormatterTest method testFormatBytes.
@SmallTest
public void testFormatBytes() {
setLocale(Locale.ENGLISH);
checkFormatBytes(0, true, "0", 0);
checkFormatBytes(0, false, "0", 0);
checkFormatBytes(1, true, "1", 1);
checkFormatBytes(1, false, "1", 1);
checkFormatBytes(12, true, "12", 12);
checkFormatBytes(12, false, "12", 12);
checkFormatBytes(123, true, "123", 123);
checkFormatBytes(123, false, "123", 123);
checkFormatBytes(812, true, "812", 812);
checkFormatBytes(812, false, "812", 812);
checkFormatBytes(912, true, "0.89", 911);
checkFormatBytes(912, false, "0.89", 911);
checkFormatBytes(9123, true, "8.9", 9113);
checkFormatBytes(9123, false, "8.91", 9123);
checkFormatBytes(9123000, true, "8.7", 9122611);
checkFormatBytes(9123000, false, "8.70", 9122611);
checkFormatBytes(-1, true, "-1", -1);
checkFormatBytes(-1, false, "-1", -1);
checkFormatBytes(-912, true, "-0.89", -911);
checkFormatBytes(-912, false, "-0.89", -911);
// Missing FLAG_CALCULATE_ROUNDED case.
BytesResult r = Formatter.formatBytes(getContext().getResources(), 1, 0);
assertEquals("1", r.value);
// Didn't pass FLAG_CALCULATE_ROUNDED
assertEquals(0, r.roundedBytes);
// Make sure it works on different locales.
setLocale(new Locale("es", "ES"));
checkFormatBytes(9123000, false, "8,70", 9122611);
}
use of android.text.format.Formatter.BytesResult in project platform_frameworks_base by android.
the class FormatterTest method checkFormatBytes.
private void checkFormatBytes(long bytes, boolean useShort, String expectedString, long expectedRounded) {
BytesResult r = Formatter.formatBytes(getContext().getResources(), bytes, Formatter.FLAG_CALCULATE_ROUNDED | (useShort ? Formatter.FLAG_SHORTER : 0));
assertEquals(expectedString, r.value);
assertEquals(expectedRounded, r.roundedBytes);
}
use of android.text.format.Formatter.BytesResult in project platform_frameworks_base by android.
the class FormatterTest method testFormatBytes.
@SmallTest
public void testFormatBytes() {
setLocale(Locale.ENGLISH);
checkFormatBytes(0, true, "0", 0);
checkFormatBytes(0, false, "0", 0);
checkFormatBytes(1, true, "1", 1);
checkFormatBytes(1, false, "1", 1);
checkFormatBytes(12, true, "12", 12);
checkFormatBytes(12, false, "12", 12);
checkFormatBytes(123, true, "123", 123);
checkFormatBytes(123, false, "123", 123);
checkFormatBytes(812, true, "812", 812);
checkFormatBytes(812, false, "812", 812);
checkFormatBytes(912, true, "0.89", 911);
checkFormatBytes(912, false, "0.89", 911);
checkFormatBytes(9123, true, "8.9", 9113);
checkFormatBytes(9123, false, "8.91", 9123);
checkFormatBytes(9123000, true, "8.7", 9122611);
checkFormatBytes(9123000, false, "8.70", 9122611);
checkFormatBytes(-1, true, "-1", -1);
checkFormatBytes(-1, false, "-1", -1);
checkFormatBytes(-912, true, "-0.89", -911);
checkFormatBytes(-912, false, "-0.89", -911);
// Missing FLAG_CALCULATE_ROUNDED case.
BytesResult r = Formatter.formatBytes(getContext().getResources(), 1, 0);
assertEquals("1", r.value);
// Didn't pass FLAG_CALCULATE_ROUNDED
assertEquals(0, r.roundedBytes);
// Make sure it works on different locales.
setLocale(new Locale("es", "ES"));
checkFormatBytes(9123000, false, "8,70", 9122611);
}
Aggregations