forked from alibaba/fastjson2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat add testcases for issue alibaba#1828 and alibaba#1874
- Loading branch information
1 parent
d2694b4
commit 3af27dd
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
core/src/test/java/com/alibaba/fastjson2/issues_1800/Issue1828.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,25 @@ | ||
package com.alibaba.fastjson2.issues_1800; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class Issue1828 { | ||
private static final int SIZE = 50 * 1024 * 1024; | ||
|
||
@Test | ||
public void test() { | ||
DTO dto = new DTO(); | ||
dto.setVedioBytes(new byte[SIZE]); | ||
String json = JSON.toJSONString(dto, JSONWriter.Feature.LargeObject); | ||
assertEquals(SIZE, JSON.parseObject(json, DTO.class).getVedioBytes().length); | ||
} | ||
|
||
@Data | ||
public class DTO { | ||
private byte[] vedioBytes; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
core/src/test/java/com/alibaba/fastjson2/issues_1800/Issue1874.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,32 @@ | ||
package com.alibaba.fastjson2.issues_1800; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONWriter; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class Issue1874 { | ||
@Test | ||
public void test() { | ||
List<TestJson> list = new ArrayList<>(); | ||
list.add(new TestJson(true, Boolean.FALSE)); | ||
list.add(new TestJson(false, Boolean.TRUE)); | ||
String json = JSON.toJSONString(list, JSONWriter.Feature.WriteBooleanAsNumber); | ||
assertEquals("[{\"b\":1,\"b2\":0},{\"b\":0,\"b2\":1}]", json); | ||
List<TestJson> list2 = JSON.parseArray(json, TestJson.class); | ||
assertEquals(list, list2); | ||
} | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public static class TestJson { | ||
private boolean b; | ||
private Boolean b2; | ||
} | ||
} |