public void BitArrayFactory_InvalidSize() { try { BitArrayFactory.Create(-1); Assert.Fail(); } catch (ArgumentOutOfRangeException) { } }
public void BitArray_ManOrBoy_Set() { for (var capacity = 0; capacity < 100; capacity++) { for (var i = 0; i < capacity; i++) { var arr = BitArrayFactory.Create(capacity); arr[i] = true; for (var j = 0; j < capacity; j++) { Assert.AreEqual(arr[j], i == j); } } } }
public void BitArray_SetAll() { for (var capacity = 0; capacity < 100; capacity++) { for (var i = 0; i < capacity; i++) { var arr = BitArrayFactory.Create(capacity); arr.SetAll(true); for (var j = 0; j < capacity; j++) { Assert.AreEqual(arr[j], true); } arr.SetAll(false); for (var j = 0; j < capacity; j++) { Assert.AreEqual(arr[j], false); } // The difference from above is that we set all to false first then set to true arr = BitArrayFactory.Create(capacity); arr.SetAll(false); for (var j = 0; j < capacity; j++) { Assert.AreEqual(arr[j], false); } arr.SetAll(true); for (var j = 0; j < capacity; j++) { Assert.AreEqual(arr[j], true); } } } }
public void BitArray_Factory_ReturnsCorrectlySizedType() { // i = 0 is hoisted out var arr = BitArrayFactory.Create(0); Assert.AreEqual(arr.Count, 0); for (int i = 1; i < 100; i++) { arr = BitArrayFactory.Create(i); Assert.AreEqual(arr.Count, i); arr[i - 1] = true; try { arr[i] = false; Assert.Fail(); } catch (ArgumentOutOfRangeException) { } } }
public void BitArray_EdgeCases() { // i = 0 is hoisted out var arr = BitArrayFactory.Create(0); try { var dummy = arr[0]; Assert.Fail(); } catch (ArgumentOutOfRangeException) { } for (int i = 1; i < 100; i++) { arr = BitArrayFactory.Create(i); try { var dummy = arr[-1]; Assert.Fail(); } catch (ArgumentOutOfRangeException) { } try { var dummy = arr[i]; Assert.Fail(); } catch (ArgumentOutOfRangeException) { } } }