OLINGO-1150: The precision and scale checks are being made on exponential form than the denormalized form
This commit is contained in:
parent
03a02d2d69
commit
f0188a6ecb
|
@ -74,8 +74,13 @@ public final class EdmDecimal extends SingletonPrimitiveType {
|
|||
private static boolean validatePrecisionAndScale(final String value, final Integer precision,
|
||||
final Integer scale) {
|
||||
|
||||
final Matcher matcher = PATTERN.matcher(value);
|
||||
Matcher matcher = PATTERN.matcher(value);
|
||||
matcher.matches();
|
||||
if (matcher.group(3) != null) {
|
||||
String plainValue = new BigDecimal(value).toPlainString();
|
||||
matcher = PATTERN.matcher(plainValue);
|
||||
matcher.matches();
|
||||
}
|
||||
final int significantIntegerDigits = "0".equals(matcher.group(1)) ? 0 : matcher.group(1).length();
|
||||
final int decimals = matcher.group(2) == null ? 0 : matcher.group(2).length();
|
||||
return (precision == null || precision >= significantIntegerDigits + decimals)
|
||||
|
|
|
@ -99,6 +99,8 @@ public class EdmDecimalTest extends PrimitiveTypeBaseTest {
|
|||
assertEquals(new BigDecimal("12.3"), instance.valueOfString("12.3", null, null, 3, 1, null, BigDecimal.class));
|
||||
assertEquals(new BigDecimal("31991163"), instance.valueOfString("3.1991163E7", null, null, 8, 7,
|
||||
null, BigDecimal.class));
|
||||
assertEquals(new BigDecimal("31991163.34"),
|
||||
instance.valueOfString("3.199116334E7", null, null, 10, 2, null, BigDecimal.class));
|
||||
|
||||
expectFacetsErrorInValueOfString(instance, "0.5", null, null, null, null, null);
|
||||
expectFacetsErrorInValueOfString(instance, "-1234", null, null, 2, null, null);
|
||||
|
|
Loading…
Reference in New Issue