MCPcopy Create free account
hub / github.com/LianjiaTech/json-diff / PathModuleTest

Class PathModuleTest

src/test/java/com/ke/diff/model/PathModuleTest.java:18–70  ·  view source on GitHub ↗

PathModule Tester. @author @version 1.0 @since 2月 28, 2022

Source from the content-addressed store, hash-verified

16 * @since <pre>2月 28, 2022</pre>
17 */
18public class PathModuleTest {
19 /**
20 * 测试新增路径方法是否正常
21 * Method: addAllpath(String lastPath)
22 */
23 @Test
24 public void testAddAllpath() {
25 PathModule pathModule = new PathModule();
26 pathModule.addAllpath("a");
27 assertEquals("a", pathModule.getLeftPath().getLast());
28 //判断路径是否可以加入null
29 pathModule.addAllpath(null);
30 assertNull(pathModule.getLeftPath().getLast());
31 assertEquals(2, pathModule.getLeftPath().size());
32 }
33
34 /**
35 * 测试删除路径方法是否正常
36 * Method: removeAllLastPath()
37 */
38 @Test
39 public void testRemoveAllLastPath() {
40 PathModule pathModule = new PathModule();
41 pathModule.addAllpath("a");
42 assertEquals("a", pathModule.getLeftPath().getLast());
43 //判断路径是否可以加入null
44 pathModule.addAllpath(null);
45 pathModule.addAllpath(null);
46 //删除路径
47 pathModule.removeAllLastPath();
48 assertNull(pathModule.getLeftPath().getLast());
49 assertEquals(2, pathModule.getLeftPath().size());
50 //删除路径
51 pathModule.removeAllLastPath();
52 assertEquals(pathModule.getLeftPath().getLast(),"a");
53 assertEquals(1, pathModule.getLeftPath().size());
54 //路径为空时
55 pathModule.removeAllLastPath();
56 assertEquals(pathModule.getLeftPath(),new LinkedList<>());
57 assertEquals(0, pathModule.getLeftPath().size());
58 }
59
60 /**
61 * 如果路径为空时删除路径,抛出异常
62 * Method: removeAllLastPath1()
63 */
64 @Test(expected = NoSuchElementException.class)
65 public void testRemoveAllLastPath1() {
66 PathModule pathModule = new PathModule();
67 //如果路径为空时删除路径,抛出异常
68 pathModule.removeAllLastPath();
69 }
70}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected