From 7ad781c02685c979d8efa3fb5542e247d8be96e7 Mon Sep 17 00:00:00 2001 From: Roozbeh Pournader Date: Wed, 29 Jun 2016 16:50:21 -0700 Subject: [PATCH] Fix failing unit tests for android.text.format.Formatter An update was needed for I34ae16bb68a28e60b09a7c17ac3b1d5ab9ddbeea, but was forgotten. The updated tests assume standardized SI rounding, using powers of 1000 instead of the previous powers of 1024. Bug: 27672362 Bug: 29871955 Change-Id: Ib42124e9ec24bcb1309c3c940c1d830a18c4802f --- .../android/text/format/FormatterTest.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/tests/coretests/src/android/text/format/FormatterTest.java b/core/tests/coretests/src/android/text/format/FormatterTest.java index be6e7ea5965ed..561aec432c87f 100644 --- a/core/tests/coretests/src/android/text/format/FormatterTest.java +++ b/core/tests/coretests/src/android/text/format/FormatterTest.java @@ -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,