Beispiel #1
0
        public void Test_SubGridTreeBitMask_SetOp_AND()
        {
            var mask = new SubGridTreeBitMask();

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    int x = i * 10;
                    int y = j * 10;

                    mask.SetCell(x, y, true);
                }
            }

            int expectedBitCount = 10000;

            mask.CountBits().Should().Be(expectedBitCount);

            // Make a copy of mask
            var secondMask = new SubGridTreeBitMask();

            secondMask.SetOp_OR(mask);
            secondMask.CountBits().Should().Be(expectedBitCount);

            // Check ANDing mask and second mask results in the same bit count
            secondMask.SetOp_AND(mask);
            secondMask.CountBits().Should().Be(expectedBitCount);

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    int x = i * 10;
                    int y = j * 10;

                    mask[x, y].Should().BeTrue();
                }
            }

            // Check ANDing with empty mask clears all bits in mask
            var emptyMask = new SubGridTreeBitMask();

            emptyMask.CountBits().Should().Be(0);
            mask.SetOp_AND(emptyMask);

            mask.CountBits().Should().Be(0);
        }
Beispiel #2
0
        public void Test_SubGridTreeBitMask_RemoveLeafOwningCell()
        {
            var mask = new SubGridTreeBitMask();

            // Check removing non-existing leaf is a null op
            mask.RemoveLeafOwningCell(0, 0);

            // Add a cell (causing a leaf to be added), then remove it
            mask[0, 0] = true;
            mask.CountBits().Should().Be(1);
            mask.CountLeafSubGridsInMemory().Should().Be(1);

            mask.RemoveLeafOwningCell(0, 0);
            mask.CountBits().Should().Be(0);
            mask.CountLeafSubGridsInMemory().Should().Be(0);
        }
Beispiel #3
0
        public void Test_SubGridTreeBitMask_SetOp_OR()
        {
            var mask = new SubGridTreeBitMask();

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    int x = i * 10;
                    int y = j * 10;

                    mask.SetCell(x, y, true);
                }
            }

            int expectedBitCount = 10000;

            mask.CountBits().Should().Be(expectedBitCount);

            // Make a copy of mask
            var secondMask = new SubGridTreeBitMask();

            secondMask.SetOp_OR(mask);
            secondMask.CountBits().Should().Be(expectedBitCount);

            var thirdMask = new SubGridTreeBitMask();

            secondMask.SetOp_OR(thirdMask);
            secondMask.CountBits().Should().Be(expectedBitCount);

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    int x = i * 10;
                    int y = j * 10;

                    secondMask[x, y].Should().BeTrue();
                }
            }
        }
Beispiel #4
0
        public void Test_SubGridTreeBitMask_CountBits()
        {
            var mask = new SubGridTreeBitMask();

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    int x = i * 10;
                    int y = j * 10;

                    mask.SetCell(x, y, true);
                }
            }

            mask.CountBits().Should().Be(10000);
        }