summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
464009b)
When we have a maximum-length string we end up reporting running out of
fraction limit. Fix this by correctly accounting for the period.
JIRA: YANGTOOLS-1321
Change-Id: I40b70400004d39a923b536db8b47784d3659bd4a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
5d46adb7935241534c69b00a13593f3e8d4ec7d6)
- final int fracLimit = MAX_FRACTION_DIGITS - intLen;
+ final int fracLimit = MAX_FRACTION_DIGITS - intLen + 1;
byte fracLen = 0;
long fracPart = 0;
for (; idx <= limit; idx++, fracLen++) {
byte fracLen = 0;
long fracPart = 0;
for (; idx <= limit; idx++, fracLen++) {
Decimal64.valueOf("0.12345678901234568");
}
Decimal64.valueOf("0.12345678901234568");
}
+ @Test
+ public void testFractionLimits() {
+ Decimal64.valueOf("922337203685477580.7");
+ Decimal64.valueOf("9.223372036854775807");
+
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("922337203685477580.71"));
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("9.2233720368547758071"));
+ }
+
@Test
public void testParseTooLongString() {
assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("1234567890123456789"));
@Test
public void testParseTooLongString() {
assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("1234567890123456789"));
@Test
public void testParseTooLongDecimal() {
@Test
public void testParseTooLongDecimal() {
- assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0.123456789012345689"));
+ assertThrows(NumberFormatException.class, () -> Decimal64.valueOf("0.1234567890123456789"));