diff options
author | Victor Chang <vichang@google.com> | 2024-02-20 17:45:25 +0000 |
---|---|---|
committer | Victor Chang <vichang@google.com> | 2024-02-20 17:46:48 +0000 |
commit | 420fb204229d2581ec4653d8f8c4b009007d7d5a (patch) | |
tree | b664bbddaa9303b48921fabba4c345a7c429e0fe | |
parent | 425838d0309e9314b986114c4a0a08957dd7752f (diff) | |
download | libcore-420fb204229d2581ec4653d8f8c4b009007d7d5a.tar.gz |
Add tests for StrictMath
Fix: 325776037
Fix: 325776189
Fix: 325776482
Fix: 325776601
Fix: 325776680
Test: atest CtsLibcoreOjTestCases:test.java.lang.Math.ExactArithTests
Change-Id: I4dcb10261bf2fddaf41e575ab8dc4b48b5883663
-rw-r--r-- | ojluni/src/test/java/lang/Math/ExactArithTests.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ojluni/src/test/java/lang/Math/ExactArithTests.java b/ojluni/src/test/java/lang/Math/ExactArithTests.java index 34fa57221f3..d2dbc84a01b 100644 --- a/ojluni/src/test/java/lang/Math/ExactArithTests.java +++ b/ojluni/src/test/java/lang/Math/ExactArithTests.java @@ -168,6 +168,12 @@ public class ExactArithTests { fail("FAIL: int Math.divideExact(" + x + " / " + y + ") = " + z + "; expected: " + quotient); } + // Android-added: Test functionally-equivalent StrictMath version. + z = StrictMath.divideExact(x, y); + if (z != quotient) { + fail("FAIL: int StrictMath.divideExact(" + x + " / " + y + ") = " + + z + "; expected: " + q); + } } catch (ArithmeticException ex) { if (!exceptionExpected) { fail("FAIL: int Math.divideExact(" + x + " / " + y + ")" + @@ -196,6 +202,12 @@ public class ExactArithTests { fail("FAIL: int Math.floorDivExact(" + x + " / " + y + ") = " + z + "; expected: " + q); } + // Android-added: Test functionally-equivalent StrictMath version. + z = StrictMath.floorDivExact(x, y); + if (z != q) { + fail("FAIL: int StrictMath.floorDivExact(" + x + " / " + y + ") = " + + z + "; expected: " + q); + } } catch (ArithmeticException ex) { if (!exceptionExpected) { fail("FAIL: int Math.floorDivExact(" + x + " / " + y + ")" + @@ -224,6 +236,11 @@ public class ExactArithTests { fail("FAIL: int Math.ceilDivExact(" + x + " / " + y + ") = " + z + "; expected: " + q); } + // Android-added: Test functionally-equivalent StrictMath version. + if (z != StrictMath.ceilDivExact(x, y)) { + fail("FAIL: int StrictMath.ceilDivExact(" + x + " / " + y + ") = " + + z + "; expected: " + q); + } } catch (ArithmeticException ex) { if (!exceptionExpected) { fail("FAIL: int Math.ceilDivExact(" + x + " / " + y + ")" + @@ -411,6 +428,12 @@ public class ExactArithTests { fail("FAIL: long Math.floorDivExact(" + x + " / " + y + ") = " + z + "; expected: " + q); } + // Android-added: Test functionally-equivalent StrictMath version. + z = StrictMath.floorDivExact(x, y); + if (z != q) { + fail("FAIL: long StrictMath.floorDivExact(" + x + " / " + y + ") = " + + z + "; expected: " + q); + } } catch (ArithmeticException ex) { if (!exceptionExpected) { fail("FAIL: long Math.floorDivExact(" + x + " / " + y + ")" + @@ -439,6 +462,12 @@ public class ExactArithTests { fail("FAIL: long Math.ceilDivExact(" + x + " / " + y + ") = " + z + "; expected: " + q); } + // Android-added: Test functionally-equivalent StrictMath version. + z = StrictMath.ceilDivExact(x, y); + if (z != q) { + fail("FAIL: long StrictMath.ceilDivExact(" + x + " / " + y + ") = " + + z + "; expected: " + q); + } } catch (ArithmeticException ex) { if (!exceptionExpected) { fail("FAIL: long Math.ceilDivExact(" + x + " / " + y + ")" + |