Skip to content

Commit 0a8b2b0

Browse files
author
mpv1989
committed
Fix Json parsing of negative long
1 parent bdfcf07 commit 0a8b2b0

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v1.0.14 (2017-11-27)
2+
---------------------------
3+
* fixed Json parsing of negative long
4+
15
v1.0.13 (2017-11-03)
26
---------------------------
37
* fixed deserialization of BigDecimal

src/main/java/com/arangodb/velocypack/VPackParser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private void parse(
283283
} else if (value.isDouble()) {
284284
json.append(value.getAsDouble());
285285
} else if (value.isInt()) {
286-
json.append(value.getAsInt());
286+
json.append(value.getAsLong());
287287
} else if (value.isNumber()) {
288288
json.append(value.getAsNumber());
289289
} else if (value.isDate()) {

src/test/java/com/arangodb/velocypack/VPackParserTest.java

+35
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,39 @@ public void negativeInt() {
537537
assertThat(json, is("-32"));
538538
}
539539

540+
@Test
541+
public void negativeIntAsJson() throws VPackException {
542+
final VPackParser parser = new VPackParser.Builder().build();
543+
final String json = parser.toJson(new VPackBuilder().add(-100).slice());
544+
assertThat(json, is("-100"));
545+
}
546+
547+
@Test
548+
public void negativeIntAsJson2() throws VPackException {
549+
final VPackParser parser = new VPackParser.Builder().build();
550+
final String json = parser.toJson(new VPackBuilder().add(-300).slice());
551+
assertThat(json, is("-300"));
552+
}
553+
554+
@Test
555+
public void negativeLongAsJson() throws VPackException {
556+
final VPackParser parser = new VPackParser.Builder().build();
557+
final String json = parser.toJson(new VPackBuilder().add(-100L).slice());
558+
assertThat(json, is("-100"));
559+
}
560+
561+
@Test
562+
public void negativeLongAsJson2() throws VPackException {
563+
final VPackParser parser = new VPackParser.Builder().build();
564+
final String json = parser.toJson(new VPackBuilder().add(-300L).slice());
565+
assertThat(json, is("-300"));
566+
}
567+
568+
@Test
569+
public void negativeLongAsJson3() throws VPackException {
570+
final VPackParser parser = new VPackParser.Builder().build();
571+
final String json = parser.toJson(new VPackBuilder().add(-62135596800L).slice());
572+
assertThat(json, is("-62135596800"));
573+
}
574+
540575
}

0 commit comments

Comments
 (0)