-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix for parse plus first number #425
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
core/src/test/java/com/alibaba/fastjson2/JSONReaderTest1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.alibaba.fastjson2; | ||
|
||
import com.alibaba.fastjson2_vo.*; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class JSONReaderTest1 { | ||
@Test | ||
public void test() { | ||
String str = "{\"v0000\":+000.00}"; | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(LongValue1.class).getV0000()); | ||
} | ||
} | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(Long1.class).getV0000()); | ||
} | ||
} | ||
|
||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(Int1.class).getV0000()); | ||
} | ||
} | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(Integer1.class).getV0000()); | ||
} | ||
} | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(FloatValue1.class).getV0000()); | ||
} | ||
} | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(Float1.class).getV0000()); | ||
} | ||
} | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(DoubleValue1.class).getV0000()); | ||
} | ||
} | ||
{ | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(0, jsonReader.read(Double1.class).getV0000()); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testDecimal() { | ||
String str = "{\"id\":+000.00}"; | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(new BigDecimal("0.00"), jsonReader.read(BigDecimal1.class).getId()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testInteger() { | ||
String str = "{\"id\":+000.00}"; | ||
JSONReader[] jsonReaders = TestUtils.createJSONReaders(str); | ||
for (JSONReader jsonReader : jsonReaders) { | ||
assertEquals(BigInteger.ZERO, jsonReader.read(BigInteger1.class).getId()); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
core/src/test/java/com/alibaba/fastjson2/issues/Issue425.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.alibaba.fastjson2.issues; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2_vo.LongValue1; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue425 { | ||
@Test | ||
public void test() { | ||
String str = "{\"v0000\":+000.00}"; | ||
assertEquals(0, JSON.parseObject(str, LongValue1.class).getV0000()); | ||
} | ||
} |