Beispiel #1
0
        private void testIsEmpty(BasicStack <DSString> the_stack)
        {
            //check while not empty
            Assert.IsFalse(the_stack.isEmpty());

            //after empty
            the_stack.clear();
            Assert.IsTrue(the_stack.isEmpty());

            //after re-addition
            the_stack.push(new DSString("1"));
            Assert.IsFalse(the_stack.isEmpty());

            //after empty again
            the_stack.clear();
            Assert.IsTrue(the_stack.isEmpty());
        }
Beispiel #2
0
        private void testClear(BasicStack <DSString> the_stack)
        {
            //make sure size() and isEmpty() are correct before clear
            Assert.AreEqual(false, the_stack.isEmpty());
            Assert.AreEqual(10, the_stack.size());

            //after clearing
            the_stack.clear();
            Assert.AreEqual(true, the_stack.isEmpty());
            Assert.AreEqual(0, the_stack.size());

            //after readding and clearing
            the_stack.push(new DSString("13"));
            Assert.AreEqual(false, the_stack.isEmpty());
            Assert.AreEqual(1, the_stack.size());
        }
Beispiel #3
0
        private void testSize(BasicStack <DSString> the_stack)
        {
            //check after initial insertion
            Assert.AreEqual(10, the_stack.size());

            //check after removal
            the_stack.pop();
            Assert.AreEqual(9, the_stack.size());

            //check after addition
            the_stack.push(new DSString("13"));
            Assert.AreEqual(10, the_stack.size());

            //check after removing all
            the_stack.clear();
            Assert.AreEqual(0, the_stack.size());
        }
Beispiel #4
0
        private void testContains(BasicStack <DSString> the_stack)
        {
            //make sure all items are matched inside
            Assert.AreEqual(true, the_stack.contains(new DSString("0")));
            Assert.AreEqual(true, the_stack.contains(new DSString("1")));
            Assert.AreEqual(true, the_stack.contains(new DSString("2")));
            Assert.AreEqual(true, the_stack.contains(new DSString("3")));
            Assert.AreEqual(true, the_stack.contains(new DSString("4")));
            Assert.AreEqual(true, the_stack.contains(new DSString("5")));
            Assert.AreEqual(true, the_stack.contains(new DSString("6")));
            Assert.AreEqual(true, the_stack.contains(new DSString("7")));
            Assert.AreEqual(true, the_stack.contains(new DSString("8")));
            Assert.AreEqual(true, the_stack.contains(new DSString("9")));

            //check after removal
            the_stack.pop();
            Assert.AreEqual(false, the_stack.contains(new DSString("9")));

            //check after adding
            the_stack.push(new DSString("13"));
            Assert.AreEqual(true, the_stack.contains(new DSString("13")));

            //check after removing all
            the_stack.clear();
            Assert.AreEqual(false, the_stack.contains(new DSString("13")));
            Assert.AreEqual(false, the_stack.contains(new DSString("0")));
            Assert.AreEqual(false, the_stack.contains(new DSString("1")));
            Assert.AreEqual(false, the_stack.contains(new DSString("2")));
            Assert.AreEqual(false, the_stack.contains(new DSString("3")));
            Assert.AreEqual(false, the_stack.contains(new DSString("4")));
            Assert.AreEqual(false, the_stack.contains(new DSString("5")));
            Assert.AreEqual(false, the_stack.contains(new DSString("6")));
            Assert.AreEqual(false, the_stack.contains(new DSString("7")));
            Assert.AreEqual(false, the_stack.contains(new DSString("8")));
            Assert.AreEqual(false, the_stack.contains(new DSString("9")));
        }