forked from json-iterator/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCollection.java
More file actions
41 lines (36 loc) · 1.32 KB
/
TestCollection.java
File metadata and controls
41 lines (36 loc) · 1.32 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
package com.jsoniter.output;
import com.jsoniter.spi.Config;
import junit.framework.TestCase;
import java.util.HashSet;
public class TestCollection extends TestCase {
public void test_indention() {
HashSet<Integer> set = new HashSet<Integer>();
set.add(1);
Config cfg = new Config.Builder()
.encodingMode(EncodingMode.REFLECTION_MODE)
.indentionStep(2)
.build();
assertEquals("[\n" +
" 1\n" +
"]", JsonStream.serialize(cfg, set));
cfg = new Config.Builder()
.encodingMode(EncodingMode.DYNAMIC_MODE)
.indentionStep(2)
.build();
assertEquals("[\n" +
" 1\n" +
"]", JsonStream.serialize(cfg, set));
}
public void test_indention_with_empty_array() {
Config cfg = new Config.Builder()
.encodingMode(EncodingMode.REFLECTION_MODE)
.indentionStep(2)
.build();
assertEquals("[]", JsonStream.serialize(cfg, new HashSet<Integer>()));
cfg = new Config.Builder()
.encodingMode(EncodingMode.DYNAMIC_MODE)
.indentionStep(2)
.build();
assertEquals("[]", JsonStream.serialize(cfg, new HashSet<Integer>()));
}
}