aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-02-21 09:35:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-02-21 09:35:18 +0000
commit942ef2486b0d2c88d1362dae38513bd4fdf808db (patch)
treeb664bbddaa9303b48921fabba4c345a7c429e0fe
parent8f9a79ad546c953daca780a86d769674dd32b2fc (diff)
parent420fb204229d2581ec4653d8f8c4b009007d7d5a (diff)
downloadlibcore-942ef2486b0d2c88d1362dae38513bd4fdf808db.tar.gz
Merge "Add tests for StrictMath" into main
-rw-r--r--ojluni/src/test/java/lang/Math/ExactArithTests.java29
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 + ")" +