
#include "tests_stack.hpp"

#ifdef STL
	#define DEQ_VEC deque
#else
	#define DEQ_VEC vector
#endif

TEST(tests_stack_constructor)
{
	// title
	TITLE(simple test)

	ft::DEQ_VEC<T> mycont (2,VAL(200));				// ft::vector/stl::deque with 2 elements
	ft::vector<T> myvector (2,VAL(200));			// vector with 2 elements

	ft::stack<T> first;								// empty stack
	ft::stack<T> second (mycont);					// stack initialized to copy of vector

	ft::stack< T,ft::vector<T> > third;				// empty stack using vector
	ft::stack< T,ft::vector<T> > fourth (myvector);

	std::cout << "size of first: " << first.size() << '\n';
	std::cout << "size of second: " << second.size() << '\n';
	std::cout << "size of third: " << third.size() << '\n';
	std::cout << "size of fourth: " << fourth.size() << '\n';

	PRINT(first)
	PRINT(second)
	PRINT(third)
	PRINT(fourth)

	DELETE
}

TEST(tests_stack_empty)
{
	// title
	TITLE(simple test)

	ft::stack<T> mystack;
	int sum (0);

	for (int i=1;i<=10;i++) mystack.push(VAL(i));

	while (!mystack.empty())
	{
		sum += TOI(mystack.top());
		mystack.pop();
	}

	std::cout << "total: " << sum << '\n';

	PRINT(mystack)

	DELETE
}

TEST(tests_stack_size)
{
	// title
	TITLE(simple test)

	ft::stack<T> myints;
	std::cout << "0. size: " << myints.size() << '\n';

	for (int i=0; i<5; i++) myints.push(VAL(i));
	std::cout << "1. size: " << myints.size() << '\n';

	myints.pop();
	std::cout << "2. size: " << myints.size() << '\n';

	PRINT(myints)

	DELETE
}

TEST(tests_stack_top)
{
	// title
	TITLE(simple test)

	ft::stack<T> mystack;

	mystack.push(VAL(10));
	std::cout << "mystack.top() is now " << mystack.top() << '\n';
	mystack.push(VAL(20));
	std::cout << "mystack.top() is now " << mystack.top() << '\n';
	mystack.push(VAL(-12));
	std::cout << "mystack.top() is now " << mystack.top() << '\n';
	mystack.push(VAL(26));
	std::cout << "mystack.top() is now " << mystack.top() << '\n';

//	mystack.top() -= VAL(5);


	PRINT(mystack)

	DELETE
}

TEST(tests_stack_push)
{
	// title
	TITLE(simple test)

	ft::stack<T> mystack;

	for (int i=0; i<5; ++i) mystack.push(VAL(i));

	PRINT(mystack)

	DELETE
}

TEST(tests_stack_pop)
{
	// title
	TITLE(simple test)

	ft::stack<T> mystack;

	for (int i=0; i<5; ++i) mystack.push(VAL(i));

	std::cout << "Popping out elements...";
	while (!mystack.empty())
	{
		std::cout << ' ' << mystack.top();
		mystack.pop();
	}
	std::cout << '\n';

	DELETE
}
