public void WeissTest() { dictionary = new SplayDictionary <int, string>(); const int NUMS = 40000; const int GAP = 307; for (int i = GAP; i != 0; i = (i + GAP) % NUMS) { dictionary.Add(i, i.ToString()); } for (int i = 1; i < NUMS; i += 2) { dictionary.Remove(i); } Assert.AreEqual(new KeyValuePair <int, string>(2, "2"), dictionary.Minimum); Assert.AreEqual(new KeyValuePair <int, string>(NUMS - 2, (NUMS - 2).ToString()), dictionary.Maximum); for (int i = 2; i < NUMS; i += 2) { Assert.IsTrue(dictionary.ContainsKey(i)); } for (int i = 1; i < NUMS; i += 2) { Assert.IsFalse(dictionary.ContainsKey(i)); } }
public void CountTest() { dictionary = new SplayDictionary <int, string>(); dictionary.Add(5, "five"); Assert.AreEqual(1, dictionary.Count); dictionary.Add(3, "three"); Assert.AreEqual(2, dictionary.Count); dictionary.Remove(5); Assert.AreEqual(1, dictionary.Count); dictionary.Add(7, "seven"); Assert.AreEqual(2, dictionary.Count); dictionary.Add(9, "nine"); Assert.AreEqual(3, dictionary.Count); dictionary.Add(5, "five"); Assert.AreEqual(4, dictionary.Count); dictionary.Remove(7); Assert.AreEqual(3, dictionary.Count); }
public void EmptinessTest() { dictionary = new SplayDictionary <int, string>(); dictionary.Add(new KeyValuePair <int, string>(42, "forty-two")); Assert.IsFalse(dictionary.IsEmpty); }