コード例 #1
0
ファイル: SListTests.cs プロジェクト: BartonCline/gisharp
        public void TestInsertSorted()
        {
            Comparison <OpaqueInt> compareFunc = (a, b) =>
                                                 a.Value.CompareTo(b.Value);

            using (var list = new SList <OpaqueInt> ()) {
                Assume.That(list.Length, Is.EqualTo(0));
                list.InsertSorted(new OpaqueInt(1), compareFunc);
                Assert.That(list.Length, Is.EqualTo(1));

                // check that it actually sorts items
                list.InsertSorted(new OpaqueInt(3), compareFunc);
                list.InsertSorted(new OpaqueInt(2), compareFunc);
                Assert.That(list.Length, Is.EqualTo(3));
                Assert.That(list[0].Value, Is.EqualTo(1));
                Assert.That(list[1].Value, Is.EqualTo(2));
                Assert.That(list[2].Value, Is.EqualTo(3));

                // calling without a sort function is not allowed
                Assert.That(() => list.InsertSorted(new OpaqueInt(4), null),
                            Throws.ArgumentNullException);
            }

            Utility.AssertNoGLibLog();
        }