public void Test_Main() { Tree t = new Tree(); t["one"] = "two"; Assert.AreEqual("two", t["one"]); Assert.AreEqual(t.Count, 1); t.Remove("one"); Assert.AreEqual(t.Count, 0); Assert.AreEqual(null, t["one"]); }
public void Test_Clear() { Tree t = new Tree(); Assert.AreEqual(t.Count, 0); t.Clear(); Assert.AreEqual(t.Count, 0); t.Add("one", "one"); Assert.AreEqual(t.Count, 1); t.Clear(); Assert.AreEqual(t.Count, 0); }
private Tree data() { Tree t = new Tree(); t.Add("one", "one"); t["2"] = "12"; t["~"] = "2~"; t["a~"] = "3a~"; t["~a"] = "4~a"; t[" "] = "5 "; t[" "] = "6 "; Assert.AreEqual(t.Count, 7); Assert.IsTrue(t.Contains("~")); Assert.IsTrue(!t.Contains("~~")); return t; }
public void Test_Type() { Tree t = new Tree(); Assert.AreEqual("bedrock.collections.Tree", t.GetType().FullName); }
public void Test_DictIteration() { Tree sl = new Tree(); for (int i = 0; i < 4096; i++) { sl[i] = i.ToString(); } Assert.AreEqual(4096, sl.Count); int count = 0; IDictionaryEnumerator e = sl.GetEnumerator(); while (e.MoveNext()) { Assert.AreEqual(count, e.Key); Assert.AreEqual(count.ToString(), e.Value); count++; } Assert.AreEqual(4096, count); }
public void Test_Null() { Tree sl = new Tree(); sl[null] = "n"; }
public void Test_Iteration() { Tree sl = new Tree(); for (int i = 0; i < 4096; i++) { sl[i] = i.ToString(); } Assert.AreEqual(4096, sl.Count); int count = 0; foreach (DictionaryEntry de in sl) { Assert.AreEqual(count, de.Key); Assert.AreEqual(count.ToString(), de.Value); count++; } Assert.AreEqual(4096, count); }
public void Test_Lots_Random() { Tree sl = new Tree(); Random r = new Random(); int[] nums = new int[4096]; for (int i = 0; i < 4096; i++) { nums[i] = r.Next(10000); while (sl.Contains(nums[i])) { nums[i] = r.Next(10000); } sl[nums[i]] = i.ToString(); } Assert.AreEqual(4096, sl.Count); for (int i = 0; i < 4096; i++) { Assert.AreEqual(i.ToString(), sl[nums[i]]); } }
public void Test_Lots_InOrder() { Tree sl = new Tree(); for (int i = 0; i < 4096; i++) { sl[i] = i.ToString(); } Assert.AreEqual(4096, sl.Count); for (int i = 0; i < 4096; i++) { Assert.AreEqual(i.ToString(), sl[i]); } }
public TreeEnumerator(Tree t, Node n) { tree = t; mods = t.modCount; // foreach calls MoveNext before starting. Create a dummy node before the first one. current = new Node(null, null, null); current.right = first(n); }
public TreeEnumerator(Tree t) : this(t, t.root) { }