Skip to content

Commit

Permalink
Add test for convertValue with BigInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
sepe81 committed Dec 21, 2018
1 parent ba493b4 commit b58dc38
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.opensymphony.xwork2.test.annotations.Person;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DateFormat;
import java.util.*;

Expand Down Expand Up @@ -229,6 +230,24 @@ public void testPositiveDoubleValue() throws Exception {
assertEquals(94.1231233d, (Double) convertedObject, 0.0001);
}

public void testBigInteger() {
Object convertedObject = basicConverter.convertValue(null, BigInteger.class);
assertEquals(BigInteger.ZERO, convertedObject);
assertEquals(0, BigInteger.ZERO.compareTo((BigInteger) convertedObject));

convertedObject = basicConverter.convertValue(BigInteger.ZERO, BigInteger.class);
assertEquals(BigInteger.ZERO, convertedObject);
assertEquals(0, BigInteger.ZERO.compareTo((BigInteger) convertedObject));

convertedObject = basicConverter.convertValue(new BigInteger("0"), BigInteger.class);
assertEquals(BigInteger.ZERO, convertedObject);
assertEquals(0, BigInteger.ZERO.compareTo((BigInteger) convertedObject));

convertedObject = basicConverter.convertValue(BigInteger.TEN, BigInteger.class);
assertEquals(BigInteger.TEN, convertedObject);
assertEquals(0, BigInteger.TEN.compareTo((BigInteger) convertedObject));
}

public void testBigDecimal() {
Object convertedObject = basicConverter.convertValue(null, BigDecimal.class);
assertNull(convertedObject);
Expand Down

0 comments on commit b58dc38

Please sign in to comment.