Skip to content

Commit a74875d

Browse files
committed
添加新的单测
1 parent a9da144 commit a74875d

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package features.snack4.codec;
2+
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
import org.noear.snack4.ONode;
6+
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
/**
11+
*
12+
* @author noear 2025/12/28 created
13+
*
14+
*/
15+
public class LoopNestingTest {
16+
@Test
17+
public void case1() {
18+
Map<String, Object> tmp = new HashMap<>();
19+
tmp.put("a", "a");
20+
tmp.put("b", tmp);
21+
22+
String json = ONode.serialize(tmp);
23+
System.out.println(json);
24+
Assertions.assertEquals("{\"a\":\"a\"}", json);
25+
}
26+
27+
@Test
28+
public void case2() {
29+
A tmp = new A();
30+
tmp.a = "a";
31+
tmp.b = tmp;
32+
33+
String json = ONode.serialize(tmp);
34+
System.out.println(json);
35+
Assertions.assertEquals("{\"a\":\"a\"}", json);
36+
}
37+
38+
@Test
39+
public void case2_ref() {
40+
A tmp = new A();
41+
tmp.a = "a";
42+
tmp.b = tmp;
43+
44+
A a = ONode.deserialize("{\"a\":\"a\"}", A.class);
45+
Assertions.assertEquals("a", "a");
46+
assert a.b == a;
47+
}
48+
49+
public static class A {
50+
public String a;
51+
public A b;
52+
}
53+
}

0 commit comments

Comments
 (0)