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(); } } }
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); }