public void TestCloneBitSet() { // Arrange var orig = new OpenBitSet(8); orig.Set(2); orig.Set(4); orig.Set(6); orig.Set(8); // Act var clone = (OpenBitSet)orig.Clone(); clone.Set(3); // Assert Assert.AreEqual(false, orig.Get(1)); Assert.AreEqual(true, orig.Get(2)); Assert.AreEqual(false, orig.Get(3)); Assert.AreEqual(true, orig.Get(4)); Assert.AreEqual(false, orig.Get(5)); Assert.AreEqual(true, orig.Get(6)); Assert.AreEqual(false, orig.Get(7)); Assert.AreEqual(true, orig.Get(8)); Assert.AreEqual(false, clone.Get(1)); Assert.AreEqual(true, clone.Get(2)); Assert.AreEqual(true, clone.Get(3)); Assert.AreEqual(true, clone.Get(4)); Assert.AreEqual(false, clone.Get(5)); Assert.AreEqual(true, clone.Get(6)); Assert.AreEqual(false, clone.Get(7)); Assert.AreEqual(true, clone.Get(8)); }
private ISearchBits Apply(ISearchBits other, Action <OpenBitSet, OpenBitSet> operation) { var bitset = (OpenBitSet)_openBitSet.Clone(); var otherBitSet = other as SearchBits; if (otherBitSet == null) { throw new InvalidOperationException("The other bitset must be of type OpenBitSet"); } operation(bitset, otherBitSet._openBitSet); return(new SearchBits(bitset)); }