Ejemplo n.º 1
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_ForEach_Action()
        {
            // Test iteration action for empty, full and arbitrary masks
            SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled);

            int sum;

            sum = 0;
            bits.ForEach((x, y) => { if (bits.BitSet(x, y))
                                     {
                                         sum++;
                                     }
                         });
            Assert.True(sum == bits.CountBits() && sum == SubGridTreeConsts.CellsPerSubGrid, "Summation via ForEach on full mask did not give expected result");

            sum = 0;
            bits.Clear();
            bits.ForEach((x, y) => { if (bits.BitSet(x, y))
                                     {
                                         sum++;
                                     }
                         });
            Assert.True(sum == bits.CountBits() && sum == 0, "Summation via ForEach on empty mask did not give expected result");

            sum = 0;
            bits.SetBit(1, 1);
            bits.ForEach((x, y) => { if (bits.BitSet(x, y))
                                     {
                                         sum++;
                                     }
                         });
            Assert.True(sum == bits.CountBits() && sum == 1, "Summation via ForEach on mask with single bit set at (1, 1) did not give expected result");
        }
Ejemplo n.º 2
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_ForEach_Function()
        {
            // Test iteration function for empty, full and arbitrary masks
            SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);

            bits.ForEach((x, y) => { return(true); });
            Assert.Equal(bits.CountBits(), SubGridTreeConsts.CellsPerSubGrid);

            bits.Clear();
            bits.ForEach((x, y) => { return(x < 16); });
            Assert.Equal(bits.CountBits(), SubGridTreeConsts.CellsPerSubGrid / 2);

            bits.Clear();
            bits.ForEach((x, y) => { return((x == 1) && (y == 1)); });
            Assert.Equal(1, bits.CountBits());
        }