-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
129 additions
and
26 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
94 changes: 94 additions & 0 deletions
94
core/src/test/java/com/alibaba/fastjson2/issues_2500/Issue2535.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,94 @@ | ||
package com.alibaba.fastjson2.issues_2500; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class Issue2535 { | ||
@Test | ||
public void test1() { | ||
String json = "{}"; | ||
List<String> strings = JSON.parseArray(json, String.class); | ||
assertNotNull(strings); | ||
assertEquals(strings.size(), 1); | ||
assertEquals(strings.get(0), "{}"); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
String json = "\"11111\""; | ||
List<String> strings = JSON.parseArray(json, String.class); | ||
assertNotNull(strings); | ||
assertEquals(strings.size(), 1); | ||
assertEquals(strings.get(0), "11111"); | ||
} | ||
|
||
@Test | ||
public void test3() { | ||
String json = "'22222'"; | ||
List<String> strings = JSON.parseArray(json, String.class); | ||
assertNotNull(strings); | ||
assertEquals(strings.size(), 1); | ||
assertEquals(strings.get(0), "22222"); | ||
} | ||
|
||
@Test | ||
public void test4() { | ||
String json = "[]"; | ||
List<String> strings = JSON.parseArray(json, String.class); | ||
assertNotNull(strings); | ||
assertEquals(strings.size(), 0); | ||
} | ||
|
||
@Test | ||
public void test5() { | ||
String json = "11\"11111\""; | ||
assertThrows(JSONException.class, () -> { | ||
JSON.parseArray(json, String.class); | ||
}); | ||
} | ||
|
||
@Test | ||
public void test6() { | ||
String json = "22'22222'"; | ||
assertThrows(JSONException.class, () -> { | ||
JSON.parseArray(json, String.class); | ||
}); | ||
} | ||
|
||
@Test | ||
public void test7() { | ||
String json = "1{}"; | ||
assertThrows(JSONException.class, () -> { | ||
JSON.parseArray(json, String.class); | ||
}); | ||
} | ||
|
||
@Test | ||
public void test8() { | ||
String json = "a{}"; | ||
assertThrows(JSONException.class, () -> { | ||
JSON.parseArray(json, String.class); | ||
}); | ||
} | ||
|
||
@Test | ||
public void test9() { | ||
String json = "a'333'"; | ||
assertThrows(JSONException.class, () -> { | ||
JSON.parseArray(json, String.class); | ||
}); | ||
} | ||
|
||
@Test | ||
public void test10() { | ||
String json = "a\"444\""; | ||
assertThrows(JSONException.class, () -> { | ||
JSON.parseArray(json, String.class); | ||
}); | ||
} | ||
} |