public void FixedListByte128ToFixedListByte64() { var a = new FixedListByte128(); for (var i = 0; i < 126; ++i) { a.Add((byte)i); } Assert.Throws <IndexOutOfRangeException> (() => { var b = new FixedListByte64(a); }); }
public void FixedListByte128HasExpectedCapacity() { var list = new FixedListByte128(); var expectedCapacity = 126; for (int i = 0; i < expectedCapacity; ++i) { list.Add((byte)i); } Assert.Throws <IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); }); }
public void FixedListByte128Sort() { var list = new FixedListByte128(); for (var i = 0; i < 5; ++i) { list.Add((byte)(4 - i)); } list.Sort(); for (var i = 0; i < 5; ++i) { Assert.AreEqual(i, list[i]); } }
public void FixedListByte128RemoveRange() { var list = new FixedListByte128(); list.Add(0); list.Add(3); list.Add(3); list.Add(1); list.Add(2); list.RemoveRange(1, 2); for (var i = 0; i < 3; ++i) { Assert.AreEqual(i, list[i]); } }
public void FixedListByte128InsertRange() { var list = new FixedListByte128(); list.Add(0); list.Add(3); list.Add(4); list.InsertRange(1, 2); list[1] = 1; list[2] = 2; for (var i = 0; i < 5; ++i) { Assert.AreEqual(i, list[i]); } }
public void FixedListByte64ToFixedListByte128() { var a = new FixedListByte64(); for (var i = 0; i < 62; ++i) { a.Add((byte)i); } var b = new FixedListByte128(a); for (var i = 0; i < 62; ++i) { Assert.AreEqual((byte)i, b[i]); } }
public void FixedListByte128HasExpectedLayout() { var actual = new FixedListByte128(); for (var i = 0; i < 126; ++i) { actual.Add((byte)i); } unsafe { var e = stackalloc byte[128]; e[0] = (byte)((126 >> 0) & 0xFF); e[1] = (byte)((126 >> 8) & 0xFF); for (var i = 0; i < 126; ++i) { var s = (byte)i; UnsafeUtility.MemCpy(e + 2 + sizeof(byte) * i, &s, sizeof(byte)); } Assert.AreEqual(0, UnsafeUtility.MemCmp(e, &actual.length, 128)); } }