Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 5059cd9

Browse files
author
Jochen Buchholz
committed
This additional test shows the bug in the overflow detection in the
multiplyExact Method
1 parent 2c5d421 commit 5059cd9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/test/java/org/javamoney/moneta/FastMoneyTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,16 @@ public void testMultiplyLong(){
422422
} catch (ArithmeticException e) {
423423
// should happen
424424
}
425-
}
425+
try {
426+
// the maximum value for FastMoney is 92233720368547.75807
427+
// these values are lower, but the overflow detection does not work
428+
// correct.
429+
FastMoney.of(-53484567177043L, "CHF").multiply(2178802625L);
430+
fail("overflow should raise ArithmeticException");
431+
} catch (ArithmeticException e) {
432+
// should happen
433+
}
434+
}
426435

427436
/**
428437
* Test method for {@link FastMoney#multiply(double)}.

0 commit comments

Comments
 (0)