Пример #1
0
        public void Card0FullTest()
        {
            var intSet = new Kibnet.IntSet();

            intSet.Add(0);
            var card0 = intSet.root.Cards.FirstOrDefault(card => card != null);

            card0.Full  = true;
            card0.Cards = null;
            intSet.Add(0);

            Assert.True(intSet.Contains(0));
        }
Пример #2
0
        public void IterationDeleteTest(int from, int to)
        {
            var intSet = new Kibnet.IntSet();

            for (int i = from; i < to; i++)
            {
                intSet.Add(i);
            }

            for (int i = from; i < to; i++)
            {
                Assert.True(intSet.Contains(i));
                intSet.Remove(i);
                for (int j = from; j < to; j++)
                {
                    if (i >= j)
                    {
                        Assert.False(intSet.Contains(j));
                    }
                    else
                    {
                        Assert.True(intSet.Contains(j));
                    }
                }
            }
        }
Пример #3
0
        public void OneSetToStringTest()
        {
            var intSet = new Kibnet.IntSet();

            intSet.Add(1);
            foreach (int indexCard0 in intSet.root)
            {
                var card0 = intSet.root.Cards[indexCard0];
                Assert.Equal("1000000000000000000000000000000000000000000000000000000000000000", card0.ToString());
                foreach (int indexCard1 in card0)
                {
                    var card1 = card0.Cards[indexCard1];
                    Assert.Equal("1000000000000000000000000000000000000000000000000000000000000000", card1.ToString());
                    foreach (int indexCard2 in card1)
                    {
                        var card2 = card1.Cards[indexCard2];
                        Assert.Equal("1000000000000000000000000000000000000000000000000000000000000000", card2.ToString());
                        foreach (int indexCard3 in card2)
                        {
                            var card3 = card2.Cards[indexCard3];
                            Assert.Equal("0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", card3.ToString());
                            foreach (byte byteValue in card3)
                            {
                                Assert.Equal("2", byteValue.ToString());
                                break;
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        public void BoundContainsTest(int value)
        {
            var intSet = new Kibnet.IntSet();

            {
                intSet.Add(value);
            }
            Assert.True(intSet.Contains(value));
        }
Пример #5
0
        public void FullSetTest(int from, int to)
        {
            var intSet = new Kibnet.IntSet(false, true);

            intSet.Add(0);

            foreach (var i in TestHelper.GetEnumerable(from, to))
            {
                Assert.True(intSet.Contains(i));
            }
        }
Пример #6
0
        public void DoubleAddContainsTest()
        {
            var intSet = new Kibnet.IntSet();

            for (int i = 0; i < 100000; i++)
            {
                intSet.Add(i);
            }
            for (int i = 0; i < 100000; i++)
            {
                intSet.Add(i);
            }
            for (int i = 0; i < 100000; i++)
            {
                Assert.True(intSet.Contains(i));
            }
            for (int i = 100000; i < 200000; i++)
            {
                Assert.False(intSet.Contains(i));
            }
        }
Пример #7
0
        public void SimpleDeleteTest()
        {
            var intSet = new Kibnet.IntSet();

            for (int i = 100000; i < 200000; i++)
            {
                intSet.Add(i);
                Assert.True(intSet.Contains(i));
                intSet.Remove(i);
                Assert.False(intSet.Contains(i));
            }
        }
Пример #8
0
        public void NotEvensTest(int from, int to)
        {
            var intSet = new Kibnet.IntSet();

            foreach (var i in TestHelper.GetEnumerable(from, to))
            {
                if (i % 2 != 0)
                {
                    intSet.Add(i);
                }
            }

            foreach (var i in TestHelper.GetEnumerable(from, to))
            {
                if (i % 2 != 0)
                {
                    Assert.True(intSet.Contains(i));
                }
                else
                {
                    Assert.False(intSet.Contains(i));
                }
            }
        }