forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestList.java
More file actions
42 lines (37 loc) · 1.36 KB
/
TestList.java
File metadata and controls
42 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.jsoniter.output;
import com.jsoniter.spi.Config;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.Arrays;
public class TestList extends TestCase {
public void test_indention() {
Config cfg = new Config.Builder()
.encodingMode(EncodingMode.REFLECTION_MODE)
.indentionStep(2)
.build();
assertEquals("[\n" +
" 1,\n" +
" 2\n" +
"]", JsonStream.serialize(cfg, Arrays.asList(1, 2)));
cfg = new Config.Builder()
.encodingMode(EncodingMode.DYNAMIC_MODE)
.indentionStep(2)
.build();
assertEquals("[\n" +
" 1,\n" +
" 2\n" +
"]", JsonStream.serialize(cfg, Arrays.asList(1, 2)));
}
public void test_indention_with_empty_array() {
Config cfg = new Config.Builder()
.encodingMode(EncodingMode.REFLECTION_MODE)
.indentionStep(2)
.build();
assertEquals("[]", JsonStream.serialize(cfg, new ArrayList<Integer>()));
cfg = new Config.Builder()
.encodingMode(EncodingMode.DYNAMIC_MODE)
.indentionStep(2)
.build();
assertEquals("[]", JsonStream.serialize(cfg, new ArrayList<Integer>()));
}
}