public void FixedListFloat64HasExpectedCapacity() { var list = new FixedListFloat64(); var expectedCapacity = 15; for (int i = 0; i < expectedCapacity; ++i) { list.Add((float)i); } Assert.Throws <IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); }); }
public void FixedListFloat64RemoveRange() { var list = new FixedListFloat64(); 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 FixedListFloat64InsertRange() { var list = new FixedListFloat64(); 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 FixedListFloat64ToFixedListFloat32() { var a = new FixedListFloat64(); for (var i = 0; i < 15; ++i) { a.Add((float)i); } Assert.Throws <IndexOutOfRangeException> (() => { var b = new FixedListFloat32(a); }); }
public void FixedListFloat64Sort() { var list = new FixedListFloat64(); for (var i = 0; i < 5; ++i) { list.Add((float)(4 - i)); } list.Sort(); for (var i = 0; i < 5; ++i) { Assert.AreEqual(i, list[i]); } }
public void FixedListFloat64ToFixedListFloat128() { var a = new FixedListFloat64(); for (var i = 0; i < 15; ++i) { a.Add((float)i); } var b = new FixedListFloat128(a); for (var i = 0; i < 15; ++i) { Assert.AreEqual((float)i, b[i]); } }
public void FixedListFloat64HasExpectedLayout() { var actual = new FixedListFloat64(); for (var i = 0; i < 15; ++i) { actual.Add((float)i); } unsafe { var e = stackalloc byte[64]; e[0] = (byte)((15 >> 0) & 0xFF); e[1] = (byte)((15 >> 8) & 0xFF); for (var i = 0; i < 15; ++i) { var s = (float)i; UnsafeUtility.MemCpy(e + 2 + sizeof(float) * i, &s, sizeof(float)); } Assert.AreEqual(0, UnsafeUtility.MemCmp(e, &actual.length, 64)); } }