public void TestRemoveAtFast() { var a = new PtrArray <OpaqueInt> (); a.Add(_(1)); Assume.That(a.Count, Is.EqualTo(1)); a.RemoveAtFast(0); Assert.That(a.Count, Is.EqualTo(0)); a.Add(_(1)); a.Add(_(2)); a.Add(_(3)); a.Add(_(4)); Assume.That(a.Count, Is.EqualTo(4)); a.RemoveAtFast(1); Assert.That(a.Count, Is.EqualTo(3)); Assert.That(getItemAt(a, 0), Is.EqualTo(_(1))); Assert.That(getItemAt(a, 1), Is.EqualTo(_(4))); Assert.That(getItemAt(a, 2), Is.EqualTo(_(3))); Assert.That(() => a.RemoveAtFast(-1), Throws.TypeOf <ArgumentOutOfRangeException> ()); Assert.That(() => a.RemoveAtFast(3), Throws.TypeOf <ArgumentOutOfRangeException> ()); a.Dispose(); Assert.That(() => a.RemoveAtFast(0), Throws.TypeOf <ObjectDisposedException> ()); Utility.AssertNoGLibLog(); }
public void TestSort() { var a = new PtrArray <OpaqueInt> (); a.Add(_(3)); a.Add(_(1)); a.Add(_(2)); Assume.That(getItemAt(a, 0), Is.EqualTo(_(3))); Assume.That(getItemAt(a, 1), Is.EqualTo(_(1))); Assume.That(getItemAt(a, 2), Is.EqualTo(_(2))); a.Sort((x, y) => x.Value - y.Value); Assert.That(getItemAt(a, 0), Is.EqualTo(_(1))); Assert.That(getItemAt(a, 1), Is.EqualTo(_(2))); Assert.That(getItemAt(a, 2), Is.EqualTo(_(3))); Assert.That(() => a.Sort(null), Throws.TypeOf <ArgumentNullException> ()); a.Dispose(); Assert.That(() => a.Sort((x, y) => 0), Throws.TypeOf <ObjectDisposedException> ()); Utility.AssertNoGLibLog(); }