File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
main/java/org/javamoney/moneta/spi
test/java/org/javamoney/moneta Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ BigDecimal getDecimal(Number num) {
4242 @ Override
4343 BigDecimal getDecimal (Number num ) {
4444 double d = num .doubleValue ();
45- if (d == Double .NaN || d == Double . POSITIVE_INFINITY || d == Double .NEGATIVE_INFINITY ) {
45+ if (Double .isNaN ( d ) || Double .isInfinite ( d ) ) {
4646 throw new ArithmeticException ("NaN, POSITIVE_INFINITY and NEGATIVE_INFINITY cannot be used as " +
4747 "parameters for monetary operations." );
4848 }
Original file line number Diff line number Diff line change @@ -1137,4 +1137,18 @@ public void testFromInversed(){
11371137 assertEquals (m , m2 );
11381138 }
11391139
1140+ @ Test (expectedExceptions = ArithmeticException .class )
1141+ public void testCreatingFromDoubleNan (){
1142+ FastMoney .of (Double .NaN , "XXX" );
1143+ }
1144+
1145+ @ Test (expectedExceptions = ArithmeticException .class )
1146+ public void testCreatingFromDoublePositiveInfinity (){
1147+ FastMoney .of (Double .POSITIVE_INFINITY , "XXX" );
1148+ }
1149+
1150+ @ Test (expectedExceptions = ArithmeticException .class )
1151+ public void testCreatingFromDoubleNegativeInfinity (){
1152+ FastMoney .of (Double .NEGATIVE_INFINITY , "XXX" );
1153+ }
11401154}
You can’t perform that action at this time.
0 commit comments