Beispiel #1
0
        public void BoundTestScoreRangeCount()
        {
            var list = new SortSet <int, int>();

            list.Add(6, 6);
            Assert.AreEqual(1, list.GetRangeCount(0, 100));
            Assert.AreEqual(0, list.GetRangeCount(7, 100));
            Assert.AreEqual(0, list.GetRangeCount(0, 5));
            Assert.AreEqual(1, list.GetRangeCount(6, 100));

            ExceptionAssert.Throws <ArgumentOutOfRangeException>(() =>
            {
                Assert.AreEqual(0, list.GetRangeCount(800, 100));
            });
        }
Beispiel #2
0
        public void TestRank()
        {
            var n = 100;

            while (n-- > 0)
            {
                var sortSets = new SortSet <int, int>();

                sortSets.Add(1000, 85);
                sortSets.Add(999, 75);
                sortSets.Add(998, 185);
                sortSets.Add(997, 85);
                sortSets.Add(996, 185);
                sortSets.Add(995, 85);

                Assert.AreEqual(1, sortSets.GetRank(995));
                Assert.AreEqual(995, sortSets.GetElementByRank(1));
                Assert.AreEqual(997, sortSets.GetElementByRank(2));
                Assert.AreEqual(1000, sortSets.GetElementByRank(3));
                Assert.AreEqual(996, sortSets.GetElementByRank(4));
                Assert.AreEqual(998, sortSets.GetElementByRank(5));

                var i     = 100;
                var faild = 0;
                while (i-- > 0)
                {
                    Assert.AreEqual(3, sortSets.GetRangeCount(80, 90));
                }
                Console.WriteLine(faild);
            }
        }
Beispiel #3
0
        public void ScoreRangeCount()
        {
            var list = new SortSet <int, int>();
            var lst  = new List <int>();
            int num  = 50000;
            var rand = new System.Random();

            for (var i = 0; i < num; i++)
            {
                var s = rand.Next(0, 1000);
                list.Add(i, s);
                if (s <= 100)
                {
                    lst.Add(i);
                }
            }
            Assert.AreEqual(lst.Count, list.GetRangeCount(0, 100));
        }
Beispiel #4
0
        public void TestRank()
        {
            var sortSets = new SortSet <int, int>();

            sortSets.Add(1000, 85);
            sortSets.Add(999, 75);
            sortSets.Add(998, 185);
            sortSets.Add(997, 85);
            sortSets.Add(996, 185);
            sortSets.Add(995, 85);

            Assert.AreEqual(1, sortSets.GetRank(995));
            Assert.AreEqual(995, sortSets.GetElementByRank(1));
            Assert.AreEqual(997, sortSets.GetElementByRank(2));
            Assert.AreEqual(1000, sortSets.GetElementByRank(3));
            Assert.AreEqual(996, sortSets.GetElementByRank(4));
            Assert.AreEqual(998, sortSets.GetElementByRank(5));

            Assert.AreEqual(3, sortSets.GetRangeCount(80, 90));
        }
Beispiel #5
0
        public void EmptyListScoreRangeCount()
        {
            var list = new SortSet <int, int>();

            Assert.AreEqual(0, list.GetRangeCount(0, 100));
        }