浏览代码

Editing test cases to have a default trie that is more expressive.

Samuel Jaffe 8 年之前
父节点
当前提交
cbb8610def
共有 1 个文件被更改,包括 18 次插入12 次删除
  1. 18 12
      trie.t.h

+ 18 - 12
trie.t.h

@@ -17,10 +17,15 @@ private:
   
   void setUp() override {
     data.clear();
-    data = -1;
+    data = 1;
     data[0] = 5;
+    data[{0,1}] = 4;
+    data[{0,1,0}] = 3;
+    data[{0,1,2}] = 6;
+    data[{0,2,0}] = 7;
     data[1] = 2;
-    data[{0, 1}] = 4;
+    data[{1,1}] = 8;
+    data[{1,1,0}] = 9;
   }
   
   template <typename Iter, typename R>
@@ -34,36 +39,37 @@ private:
     }
   }
 public:
+  // Parent, Left -> Right
   void testIterationIsPreOrder() {
-    int const expected[] = { -1, 5, 4, 2 };
+    int const expected[] = { 1, 5, 4, 3, 6, 0, 7, 2, 8, 9 };
     container_equals(data.begin(), expected);
   }
   
+  // Parent, Right -> Left
   void testPostIterationIsPostOrder() {
-    int const expected[] = { -1, 2, 5, 4 };
+    int const expected[] = { 1, 2, 8, 9, 5, 0, 7, 4, 6, 3 };
     auto it = trie<int, int>::const_post_iterator{&data};
     container_equals(it, expected);
   }
 
+  // Right -> Left, Parent
   void testReverseIterationIsInvDepthFirst() {
-    int const expected[] = { 2, 4, 5, -1 };
+    int const expected[] = { 9, 8, 2, 7, 0, 6, 3, 4, 5, 1 };
     container_equals(data.crbegin(), expected);
   }
 
   void testCopyCtorIsDeepCopy() {
     trie<int, int> copy{data};
     TS_ASSERT_EQUALS(data, copy);
-    copy[{0, 1}] = 3;
+    copy[{0, 1}] = -1;
     TS_ASSERT_DIFFERS(data, copy);
   }
   
   void testEqualsConsidersPaths() {
-    trie<int, int> messed;
-    messed = -1;
-    messed[0] = 5;
-    messed[1] = 2;
-    messed[{0, 2}] = 4;
-    TS_ASSERT_DIFFERS(data, messed);
+    trie<int, int> t1, t2;
+    t1[1] = 1;
+    t2[2] = 1;
+    TS_ASSERT_DIFFERS(t1, t2);
   }
   
   void testInsertNewElementOutputsTrue() {