summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2016-02-03 18:16:07 -0800
committerHans Boehm <hboehm@google.com>2016-02-04 15:33:25 -0800
commit65a99a423182145394f96d1430e1196ae3db1663 (patch)
tree51625f3b0990b8bf85f8c0121bdd8b2ba45b140f /tests
parent9e7e50281b90f8bae4543f52fd3a49293fc94d17 (diff)
downloadandroid_packages_apps_ExactCalculator-65a99a423182145394f96d1430e1196ae3db1663.tar.gz
android_packages_apps_ExactCalculator-65a99a423182145394f96d1430e1196ae3db1663.tar.bz2
android_packages_apps_ExactCalculator-65a99a423182145394f96d1430e1196ae3db1663.zip
Copy and truncate rational results exactly
Bug: 26966394 Bug: 26175989 Provide a separate BoundedRational toString() function to handle generation of decimal strings from rational results. This ensures that rational result are always displayed as correctly truncated. Use this facility to generate an exact representation when copying a rational result, and when doing so is appropriate. Includes some minor related changes to the same code: - Refuse to copy a result that is currently being evaluated. - Increase the bound on rational size again, to make all of this more effective. - Remove one line of dead code, and fix some comments, etc. Change-Id: I5f72d5e47849ceeb2f1b6be870eb2a64edd5d508
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/calculator2/BRTest.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/src/com/android/calculator2/BRTest.java b/tests/src/com/android/calculator2/BRTest.java
index 68214d0..f287a9e 100644
--- a/tests/src/com/android/calculator2/BRTest.java
+++ b/tests/src/com/android/calculator2/BRTest.java
@@ -128,7 +128,10 @@ public class BRTest extends TestCase {
public void testBR() {
BoundedRational b = new BoundedRational(4,-6);
check(b.toString().equals("4/-6"), "toString(4/-6)");
- check(b.toNiceString().equals("-2/3"),"toNiceString(4/-6)");
+ check(b.toNiceString().equals("-2/3"), "toNiceString(4/-6)");
+ check(b.toString(1).equals("-0.6"), "(4/-6).toString(1)");
+ check(BR_15.toString(0).equals("15."), "15.toString(1)");
+ check(BR_0.toString(2).equals("0.00"), "0.toString(2)");
checkEq(BR_0, CR.valueOf(0), "0");
checkEq(BR_390, CR.valueOf(390), "390");
checkEq(BR_15, CR.valueOf(15), "15");