public void TryAppend_ExactSizeMatch() { BitArray outer = new BitArray(10); BitArray inner = new BitArray(StringToArrayOfBits("110011")); BitArray tmp = BitArrayExtender.TryAppend(outer, 4, inner); Assert.IsNull(tmp); for (int i = 0, j = 4; j < outer.Length && i < inner.Length; i++, j++) { Assert.AreEqual(inner[i], outer[j]); } }
public void TryAppend_NoOwerflow() { BitArray outer = new BitArray(10); BitArray inner = new BitArray(StringToArrayOfBits("110011")); BitArray tmp = BitArrayExtender.TryAppend(outer, 0, inner); Assert.IsNull(tmp); for (int i = 0; i < inner.Length; i++) { Assert.AreEqual(inner[i], outer[i]); } }
public void TryAppend_Owerflow() { BitArray outer = new BitArray(10); BitArray inner = new BitArray(StringToArrayOfBits("110011")); BitArray tmp = BitArrayExtender.TryAppend(outer, 5, inner); Assert.IsNotNull(tmp); for (int i = 0, j = 5; j < outer.Length && i < inner.Length; i++, j++) { Assert.AreEqual(inner[i], outer[j]); } Assert.AreEqual(true, tmp[0]); }
public void TryAppend_ExactSizeMatchAndThenOwerflow() { BitArray outer = new BitArray(10); BitArray inner = new BitArray(StringToArrayOfBits("110011")); int position = 4; BitArray tmp = BitArrayExtender.TryAppend(outer, position, inner); Assert.IsNull(tmp); for (int i = 0, j = position; j < outer.Length && i < inner.Length; i++, j++) { Assert.AreEqual(inner[i], outer[j]); } position += inner.Length; tmp = BitArrayExtender.TryAppend(outer, position, inner); Assert.IsNotNull(tmp); for (int i = 0; i < tmp.Length; i++) { Assert.AreEqual(inner[i], tmp[i]); } }