示例#1
0
        private void ListTest(LiblaryType collectionType)
        {
            try
            {
                var ma = Choise.CreateAList<int>(collectionType, 10);
                ma.Insert(5, 0);
                ma.Insert(10, 1);
                ma.Insert(15, 2);

                int a = ma.Get(0);
                int b = ma.Get(1);
                int c = ma.Get(2);

                Assert.AreEqual(a, 5);
                Assert.AreEqual(b, 10);
                Assert.AreEqual(c, 15);

                ma.Remove(1);
                a = ma.Get(1);

                Assert.AreEqual(a, 15);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Assert.AreEqual(0, 1);
            }
        }
示例#2
0
        public void QueueTest(LiblaryType collectionType)
        {
            try
            {
                var queue = Choise.CreateAQueue<int>(collectionType, 10);

                queue.Enqueue(3);
                queue.Enqueue(6);

                int a = queue.Dequeue();
                int b = queue.Dequeue();

                Assert.AreEqual(a, 3);
                Assert.AreEqual(b, 6);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Assert.AreEqual(0, 1);
            }
        }