コード例 #1
0
        public void String_DefaultCompare_ValidResult()
        {
            string s1 = "a";
            string s2 = "aa";
            string s3 = "aaa";
            string s4 = "bbbb";

            string[] expected = { s1, s2, s3, s4 };

            CustomComparer      comparer = new CustomComparer();
            BinaryTree <string> bt       = new BinaryTree <string>(comparer.Compare);

            bt.Add(s1);
            bt.Add(s2);
            bt.Add(s3);
            bt.Add(s4);

            string[] arr = bt.Inorder().ToArray();

            Assert.AreEqual(arr, expected);
        }
コード例 #2
0
        public void Point_CustomCompare_ValidResult()
        {
            Point p  = new Point(1, 2);
            Point p2 = new Point(5, 8);
            Point p3 = new Point(0, 0);
            Point p4 = new Point(5, 88);
            Point p5 = new Point(89, 888);

            Point[] expected = { p3, p, p2, p4, p5 };

            CustomComparer     comparer = new CustomComparer();
            BinaryTree <Point> bt       = new BinaryTree <Point>(comparer.Compare);

            bt.Add(p);
            bt.Add(p2);
            bt.Add(p3);
            bt.Add(p4);
            bt.Add(p5);

            Point[] arr2 = bt.Inorder().ToArray();

            Assert.AreEqual(arr2, expected);
        }