diff options
author | Hans Boehm <hboehm@google.com> | 2015-03-11 18:43:24 -0700 |
---|---|---|
committer | Hans Boehm <hboehm@google.com> | 2015-04-07 18:05:42 -0700 |
commit | 75ca21c698808b61238a3aff3e0a3dfd5ba95d0e (patch) | |
tree | 2d53dac90347479e33fe61338a81083c96585644 /src/com/android/calculator2 | |
parent | 682ff5e8ad465d74b289590e5c88e0cf129ca90b (diff) | |
download | android_packages_apps_ExactCalculator-75ca21c698808b61238a3aff3e0a3dfd5ba95d0e.tar.gz android_packages_apps_ExactCalculator-75ca21c698808b61238a3aff3e0a3dfd5ba95d0e.tar.bz2 android_packages_apps_ExactCalculator-75ca21c698808b61238a3aff3e0a3dfd5ba95d0e.zip |
Add tests, fix BoundedRational bugs
Add back some basic test infrastructure from the KitKat calculator,
updated to make it work with the current code base and asynchronous
expression evaluation.
Add BoundedRational tests, designed to check that we get all the
corner cases, particularly for degree-based trig functions, right.
Fix a couple of BoundedRational typos that caused these tests to fail.
Change-Id: I81d8f3d9bde6aa6c20f9958eabd62979babeff5b
Diffstat (limited to 'src/com/android/calculator2')
-rw-r--r-- | src/com/android/calculator2/BoundedRational.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com/android/calculator2/BoundedRational.java b/src/com/android/calculator2/BoundedRational.java index 43572d5..4a71dee 100644 --- a/src/com/android/calculator2/BoundedRational.java +++ b/src/com/android/calculator2/BoundedRational.java @@ -62,9 +62,13 @@ public class BoundedRational { } // Debug or log messages only, not pretty. + public String toString() { + return mNum.toString() + "/" + mDen.toString(); + } + public static String toString(BoundedRational r) { if (r == null) return "not a small rational"; - return r.mNum.toString() + "/" + r.mDen.toString(); + return r.toString(); } // Primarily for debugging; clearly not exact @@ -113,7 +117,7 @@ public class BoundedRational { } public int signum() { - return mDen.signum() * mDen.signum(); + return mNum.signum() * mDen.signum(); } public boolean equals(BoundedRational r) { @@ -184,7 +188,7 @@ public class BoundedRational { if (!num_sqrt.multiply(num_sqrt).equals(r.mNum)) return null; final BigInteger den_sqrt = BigInteger.valueOf(Math.round(Math.sqrt( r.mDen.doubleValue()))); - if (!num_sqrt.multiply(den_sqrt).equals(r.mDen)) return null; + if (!den_sqrt.multiply(den_sqrt).equals(r.mDen)) return null; return new BoundedRational(num_sqrt, den_sqrt); } |