public void Bitstring_Setter_ShouldThrow_WhenIncorrectSize() { var state = new SpongeState(SpongeSize.W02, 32); var bitString = new BitString("101010101010101010101010101010101010101010101010"); state.BitString = bitString; }
public void ItemAccessor_3D_Getter_ShouldReturnExpectedBit() { var bitString = new BitString("10101010101010101010101010101010101010101010101010"); var state = new SpongeState(bitString, 30); Assert.IsTrue(state[0, 0, 0]); for (var y = 0; y < 5; y++) { for (var x = 0; x < 5; x++) { for (var z = 0; z < 2; z++) { if ((z & 1) == 0) { Assert.IsTrue(state[x, y, z]); } else { Assert.IsFalse(state[x, y, z]); } } } } }
internal SpongeBit(SpongeState state, int x, int y, int z) { State = state; X = x; Y = y; Z = z; }
public void Bitstring_Setter_ShouldSetBitstring_WhenCorrectSize() { var state = new SpongeState(SpongeSize.W02, 32); var bitString = new BitString("10101010101010101010101010101010101010101010101010"); state.BitString = bitString; Assert.AreEqual("10101010101010101010101010101010101010101010101010", state.ToBinString()); }
public void Clear_ShouldClearState() { var state = new SpongeState(BitString.Random(new Random(), 48), 24); Assert.IsTrue(state.BitString.Any(b => b)); state.Clear(); Assert.IsFalse(state.BitString.Any(b => b)); }
public void SetPlane_ShouldSetPlaneBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var plane = state.GetPlane(0); state.SetPlane(plane, new[] { false, true, false, true, false, true, false, true, false, true }); Assert.AreEqual("01010101011010101010101010101010101010101010101010", state.ToBinString()); }
public void SetSlice_ShouldSetSliceBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var slice = state.GetSlice(0); state.SetSlice(slice, new bool[25]); Assert.AreEqual("00000000000000000000000000000000000000000000000000", state.ToBinString()); }
public void ItemAccessor_Flat_Setter_ShouldSetExpectedBit() { var bitString = new BitString("10101010101010101010101010101010101010101010101010"); var state = new SpongeState(bitString, 30); state[1] = true; Assert.IsTrue(state[1]); }
public void SetSheet_ShouldSetSheetBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var sheet = state.GetSheet(0); state.SetSheet(sheet, new[] { false, true, false, true, false, true, false, true, false, true }); Assert.AreEqual("01101010100110101010011010101001101010100110101010", state.ToBinString()); }
public void Xor_ShouldXorWithByteArray() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var bytes = new byte[] { 255, 255, 255, 255, 255, 255, 255 }; state.Xor(bytes); Assert.AreEqual("01010101010101010101010101010101010101010101010101", state.ToBinString()); }
public void Constructor_SpongeSizeRate_ShouldCreateExpectedState() { var state = new SpongeState(SpongeSize.W04, 72); Assert.AreEqual(100, state.Size.B); Assert.AreEqual(72, state.Rate); Assert.AreEqual(28, state.Capacity); }
public void SetRow_ShouldSetRowBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var row = state.GetRow(0, 0); state.SetRow(row, new bool[5]); Assert.AreEqual("00000000001010101010101010101010101010101010101010", state.ToBinString()); }
public void SetSlices_ShouldSetSlices() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var bits = new bool[50]; state.SetSlices(bits); Assert.AreEqual("00000000000000000000000000000000000000000000000000", state.ToBinString()); }
public void XorRow_ShouldPerformBitwiseXorWithBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var row = state.GetRow(0, 0); var bits = new[] { true, true, true, true, true }; state.XorRow(row, bits); Assert.AreEqual("00000000001010101010101010101010101010101010101010", state.ToBinString()); }
public void XorPlane_ShouldPerformBitwiseXorWithBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var plane = state.GetPlane(0); var bits = new[] { true, true, true, true, true, true, true, true, true, true }; state.XorPlane(plane, bits); Assert.AreEqual("01010101011010101010101010101010101010101010101010", state.ToBinString()); }
public void XorColumn_ShouldPerformBitwiseXorWithBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var column = state.GetColumn(0, 0); var bits = new[] { true, true, true, true, true }; state.XorColumn(column, bits); Assert.AreEqual("00101010100010101010001010101000101010100010101010", state.ToBinString()); }
public void Constructor_SpongeState_ShouldCopy() { var state = new SpongeState(BitString.Random(new Random(), 100), 72); var copy = new SpongeState(state); Assert.AreNotSame(state, copy); Assert.AreNotSame(state.BitString, copy.BitString); Assert.AreEqual(state.BitString, copy.BitString); }
public void ItemAccessor_3D_Setter_ShouldSetExpectedBit() { var bitString = new BitString("10101010101010101010101010101010101010101010101010"); var state = new SpongeState(bitString, 30); state[0, 0, 0] = false; state[0, 0, 1] = true; Assert.AreEqual("01101010101010101010101010101010101010101010101010", state.ToBinString()); }
public void XorSheet_ShouldPerformBitwiseXorWithBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var sheet = state.GetSheet(0); var bits = new[] { true, true, true, true, true, true, true, true, true, true }; state.XorSheet(sheet, bits); Assert.AreEqual("01101010100110101010011010101001101010100110101010", state.ToBinString()); }
public void GetLanes_ShouldEnumerateLanes() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); foreach (var lane in state.GetLanes()) { var bits = lane.GetBits().ToArray(); Assert.AreEqual(2, bits.Length); Assert.IsTrue(bits[0]); Assert.IsFalse(bits[1]); } }
public void SetColumn_ShouldSetColumnBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var column = state.GetColumn(0, 0); state.SetColumn(column, new[] { false, false, false, false, false }); for (var y = 0; y < 5; y++) { Assert.IsTrue(column.GetBits().All((b) => !b)); } }
public void XorSlices_ShouldPerformBitwiseXorForSlices() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var bits = new bool[50]; for (var i = 0; i < 50; i++) { bits[i] = true; } state.XorSlices(bits); Assert.AreEqual("01010101010101010101010101010101010101010101010101", state.ToBinString()); }
public void GetRows_ShouldEnumerateRows() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); foreach (var row in state.GetRows()) { var rowCheck = (row.Z & 1) == 0 ? row.GetBits().All((b) => b) : row.GetBits().All((b) => !b); Assert.IsTrue(rowCheck); } }
public void XorSlice_ShouldPerformBitwiseXorWithBits() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); var slice = state.GetSlice(0); var bits = new bool[25]; for (var i = 0; i < 25; i++) { bits[i] = true; } state.XorSlice(slice, bits); Assert.AreEqual("00000000000000000000000000000000000000000000000000", state.ToBinString()); }
public void GetIndex_Coordinates_ShouldReturnCorrectIndex() { var state = new SpongeState(new BitString("1001001011101011110011010"), 12); for (var x = 0; x < 5; x++) { for (var y = 0; y < 5; y++) { for (var z = 0; z < 1; z++) { Assert.AreEqual((5 * y) + x + z, state.GetIndex(x, y, z)); } } } }
public void GetBit_ShouldReturnExpectedBit() { var state = new SpongeState(new BitString("1010101010101010101010101"), 13); for (var i = 0; i < 25; i++) { if ((i & 1) == 0) { Assert.IsTrue(state.GetBit(i).Value); } else { Assert.IsFalse(state.GetBit(i).Value); } } }
public void GetSlices_ShouldEnumerateSlices() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); foreach (var slice in state.GetSlices()) { foreach (var column in slice.GetColumns()) { var colCheck = (column.Z & 1) == 0 ? column.GetBits().All((b) => b) : column.GetBits().All((b) => !b); Assert.IsTrue(colCheck); } } }
public void GetLane_ShouldReturnExpectedLane() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); for (var y = 0; y < 5; y++) { for (var x = 0; x < 5; x++) { var lane = state.GetLane(x, y); var bits = lane.GetBits().ToArray(); Assert.AreEqual(2, bits.Length); Assert.IsTrue(bits[0]); Assert.IsFalse(bits[1]); } } }
public void ItemAccessor_Flat_Getter_ShouldReturnExpectedBit() { var bitString = new BitString("10101010101010101010101010101010101010101010101010"); var state = new SpongeState(bitString, 30); for (var i = 0; i < state.BitString.Length; i++) { if ((i & 1) == 0) { Assert.IsTrue(state[i]); } else { Assert.IsFalse(state[i]); } } }
public void GetSlice_ShouldReturnExpectedSlice() { var state = new SpongeState(new BitString("10101010101010101010101010101010101010101010101010"), 25); for (var z = 0; z < 2; z++) { var slice = state.GetSlice(z); foreach (var column in slice.GetColumns()) { var colCheck = (column.Z & 1) == 0 ? column.GetBits().All((b) => b) : column.GetBits().All((b) => !b); Assert.IsTrue(colCheck); } } }