Exemplo n.º 1
0
	// Push one item and then pop it
    bool test2() {
	      DynamicStack stack;
	      stack.push(10);
	      ASSERT_TRUE(stack.empty() == false)
	      ASSERT_TRUE(stack.size() == 1)       
	      ASSERT_TRUE(stack.pop() == 10);
	      ASSERT_TRUE(stack.empty() == true)
	      ASSERT_TRUE(stack.size() == 0)     
	      return true;
    }
Exemplo n.º 2
0
	// Push a number of items equal to initial size and then remove most of them so that no. of items 
	//is less than half the size of the stack. As the size limit is still the initial size, no 
	//changes in its value should take place
	bool test7() {
	     DynamicStack stack;
	     for(int i = 0; i < 16; i++)
	             stack.push(i);
	     ASSERT_TRUE(stack.capacity_ == 16)
	     for(int i = 15; i >= 1; i--)
	             ASSERT_TRUE(stack.pop() == i)
	     ASSERT_TRUE(stack.capacity_ == 16)
	     ASSERT_TRUE(stack.size() == 1)
	     return true;
	}
Exemplo n.º 3
0
void test1()
{
	DynamicStack<int> iStack;

	iStack.push(1);
	iStack.push(2);
	iStack.push(3);
	iStack.push(4);
	iStack.push(5);
	iStack.push(6);

	cout << "top: " << iStack.top() << endl;
	iStack.pop();
	iStack.pop();
	cout << "top: " << iStack.top() << endl;
	iStack.pop();
	cout << "top: " << iStack.top() << endl;
	cout << "size: " << iStack.size() << endl;
	cout << "is empty: " << (iStack.isEmpty() ? "T" : "F") << endl;
	iStack.pop();
	iStack.pop();
	iStack.pop();
	cout << "is empty: " << (iStack.isEmpty() ? "T" : "F") << endl;
}