Exemple #1
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());
        }
Exemple #2
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());
        }
Exemple #3
0
        private void testPush(BasicStack <DSString> the_stack)
        {
            //items already added in initialization

            //make sure first size is right
            Assert.AreEqual(10, the_stack.size());

            //make sure first removal matches FIFO ordering
            Assert.AreEqual("9", the_stack.pop().value);

            //remove all elements and check last item to make sure removals match FIFO ordering
            string element = "";

            while (!the_stack.isEmpty())
            {
                element = the_stack.pop().value;
            }
            Assert.AreEqual("0", element);
        }