Esempio n. 1
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;
 }
Esempio n. 2
0
        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]]);
            }
        }