コード例 #1
0
        public virtual void TestAddToEnd()
        {
            BlockList <int> list = new BlockList <int>(4);
            int             cnt  = BlockList <int> .BLOCK_SIZE * 3;

            for (int i = 0; i < cnt; i++)
            {
                list.AddItem(Sharpen.Extensions.ValueOf(42 + i));
            }
            NUnit.Framework.Assert.AreEqual(cnt, list.Count);
            for (int i_1 = 0; i_1 < cnt; i_1++)
            {
                NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(42 + i_1), list[i_1]);
            }
            list.Clear();
            NUnit.Framework.Assert.AreEqual(0, list.Count);
            NUnit.Framework.Assert.IsTrue(list.IsEmpty());
            for (int i_2 = 0; i_2 < cnt; i_2++)
            {
                list.Add(i_2, Sharpen.Extensions.ValueOf(42 + i_2));
            }
            NUnit.Framework.Assert.AreEqual(cnt, list.Count);
            for (int i_3 = 0; i_3 < cnt; i_3++)
            {
                NUnit.Framework.Assert.AreEqual(Sharpen.Extensions.ValueOf(42 + i_3), list[i_3]);
            }
        }
コード例 #2
0
        public virtual void TestEmptyList()
        {
            BlockList <string> empty;

            empty = new BlockList <string>();
            NUnit.Framework.Assert.AreEqual(0, empty.Count);
            NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
            NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
            empty = new BlockList <string>(0);
            NUnit.Framework.Assert.AreEqual(0, empty.Count);
            NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
            NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
            empty = new BlockList <string>(1);
            NUnit.Framework.Assert.AreEqual(0, empty.Count);
            NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
            NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
            empty = new BlockList <string>(64);
            NUnit.Framework.Assert.AreEqual(0, empty.Count);
            NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
            NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
        }