diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-02-21 09:35:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-02-21 09:35:18 +0000 |
commit | 942ef2486b0d2c88d1362dae38513bd4fdf808db (patch) | |
tree | b664bbddaa9303b48921fabba4c345a7c429e0fe | |
parent | 8f9a79ad546c953daca780a86d769674dd32b2fc (diff) | |
parent | 420fb204229d2581ec4653d8f8c4b009007d7d5a (diff) | |
download | libcore-942ef2486b0d2c88d1362dae38513bd4fdf808db.tar.gz |
Merge "Add tests for StrictMath" into main
-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 + ")" + |