|
4 | 4 |
|
5 | 5 | namespace pboman3::domain::test {
|
6 | 6 | TEST(FuncTest, CountFilesInTree_Counts_Files) {
|
7 |
| - PboNode node("file.pbo", PboNodeType::Container, nullptr); |
8 |
| - node.createHierarchy(PboPath("f1/e1.txt")); |
9 |
| - node.createHierarchy(PboPath("f1/e2.txt")); |
10 |
| - node.createHierarchy(PboPath("f1/f2/e2.txt")); |
11 |
| - node.createHierarchy(PboPath("e2.txt")); |
| 7 | + const auto node = QSharedPointer<PboNode>::create("file.pbo", PboNodeType::Container, nullptr); |
| 8 | + node->createHierarchy(PboPath("f1/e1.txt")); |
| 9 | + node->createHierarchy(PboPath("f1/e2.txt")); |
| 10 | + node->createHierarchy(PboPath("f1/f2/e2.txt")); |
| 11 | + node->createHierarchy(PboPath("e2.txt")); |
12 | 12 |
|
13 | 13 | int count = 0;
|
14 |
| - CountFilesInTree(node, count); |
| 14 | + CountFilesInTree(*node, count); |
15 | 15 |
|
16 | 16 | ASSERT_EQ(count, 4);
|
17 | 17 | }
|
18 | 18 |
|
19 |
| - TEST(FuncTest, FindDirectChild_Finds_Child_Case_Insensitively_Const) { |
20 |
| - PboNode node("file.pbo", PboNodeType::Container, nullptr); |
21 |
| - node.createHierarchy(PboPath("e1.txt")); |
22 |
| - node.createHierarchy(PboPath("e2.txt")); |
23 |
| - PboNode* e3 = node.createHierarchy(PboPath("e3.txt")); |
24 |
| - |
25 |
| - const PboNode* found = FindDirectChild(const_cast<const PboNode*>(&node), "E3.TxT"); |
26 |
| - |
27 |
| - ASSERT_EQ(e3, found); |
28 |
| - } |
29 |
| - |
30 |
| - TEST(FuncTest, FindDirectChild_Returns_Null_Const) { |
31 |
| - PboNode node("file.pbo", PboNodeType::Container, nullptr); |
32 |
| - node.createHierarchy(PboPath("e1.txt")); |
33 |
| - node.createHierarchy(PboPath("e2.txt")); |
34 |
| - node.createHierarchy(PboPath("e3.txt")); |
35 |
| - |
36 |
| - const PboNode* found = FindDirectChild(const_cast<const PboNode*>(&node), "e4.txt"); |
37 |
| - |
38 |
| - ASSERT_EQ(found, nullptr); |
39 |
| - } |
40 |
| - |
41 |
| - TEST(FuncTest, FindDirectChild_Finds_Child_Case_Insensitively_NonConst) { |
42 |
| - PboNode node("file.pbo", PboNodeType::Container, nullptr); |
43 |
| - node.createHierarchy(PboPath("e1.txt")); |
44 |
| - node.createHierarchy(PboPath("e2.txt")); |
45 |
| - PboNode* e3 = node.createHierarchy(PboPath("e3.txt")); |
46 |
| - |
47 |
| - const PboNode* found = FindDirectChild(&node, "E3.TxT"); |
48 |
| - |
49 |
| - ASSERT_EQ(e3, found); |
50 |
| - } |
51 |
| - |
52 |
| - TEST(FuncTest, FindDirectChild_Returns_Null_NonConst) { |
53 |
| - PboNode node("file.pbo", PboNodeType::Container, nullptr); |
54 |
| - node.createHierarchy(PboPath("e1.txt")); |
55 |
| - node.createHierarchy(PboPath("e2.txt")); |
56 |
| - node.createHierarchy(PboPath("e3.txt")); |
57 |
| - |
58 |
| - const PboNode* found = FindDirectChild(&node, "e4.txt"); |
59 |
| - |
60 |
| - ASSERT_EQ(found, nullptr); |
61 |
| - } |
62 |
| - |
63 | 19 | TEST(FuncTest, IsPathConflict_Functional) {
|
64 |
| - PboNode root("file-name", PboNodeType::Container, nullptr); |
65 |
| - ASSERT_EQ(root.depth(), 0); |
| 20 | + const auto root = QSharedPointer<PboNode>::create("file-name", PboNodeType::Container, nullptr); |
| 21 | + ASSERT_EQ(root->depth(), 0); |
66 | 22 |
|
67 |
| - root.createHierarchy(PboPath("e1.txt")); |
68 |
| - root.createHierarchy(PboPath("f2/e2.txt")); |
| 23 | + root->createHierarchy(PboPath("e1.txt")); |
| 24 | + root->createHierarchy(PboPath("f2/e2.txt")); |
69 | 25 |
|
70 |
| - ASSERT_TRUE(IsPathConflict(&root, PboPath("e1.txT"))); |
71 |
| - ASSERT_TRUE(IsPathConflict(&root, PboPath("f2"))); |
72 |
| - ASSERT_TRUE(IsPathConflict(&root, PboPath("F2/e2.Txt"))); |
73 |
| - ASSERT_TRUE(IsPathConflict(&root, PboPath("f2/E2.txt/e4.txt"))); |
| 26 | + ASSERT_TRUE(IsPathConflict(root.get(), PboPath("e1.txT"))); |
| 27 | + ASSERT_TRUE(IsPathConflict(root.get(), PboPath("f2"))); |
| 28 | + ASSERT_TRUE(IsPathConflict(root.get(), PboPath("F2/e2.Txt"))); |
| 29 | + ASSERT_TRUE(IsPathConflict(root.get(), PboPath("f2/E2.txt/e4.txt"))); |
74 | 30 |
|
75 |
| - ASSERT_FALSE(IsPathConflict(&root, PboPath("e2.txt"))); |
76 |
| - ASSERT_FALSE(IsPathConflict(&root, PboPath("f2/e3.txt"))); |
77 |
| - ASSERT_FALSE(IsPathConflict(&root, PboPath("f3/e4.txt"))); |
| 31 | + ASSERT_FALSE(IsPathConflict(root.get(), PboPath("e2.txt"))); |
| 32 | + ASSERT_FALSE(IsPathConflict(root.get(), PboPath("f2/e3.txt"))); |
| 33 | + ASSERT_FALSE(IsPathConflict(root.get(), PboPath("f3/e4.txt"))); |
78 | 34 | }
|
79 | 35 | }
|
0 commit comments