ready for surrender
This commit is contained in:
22
Makefile
22
Makefile
@@ -34,7 +34,7 @@ NAME = containers
|
|||||||
NAME_FT = containers_ft
|
NAME_FT = containers_ft
|
||||||
NAME_STL = containers_stl
|
NAME_STL = containers_stl
|
||||||
|
|
||||||
CC = g++
|
CC = clang++
|
||||||
EXT = cpp
|
EXT = cpp
|
||||||
|
|
||||||
CFLAGS = -Wall -Wextra -Werror $(INCLUDES)
|
CFLAGS = -Wall -Wextra -Werror $(INCLUDES)
|
||||||
@@ -61,14 +61,14 @@ D_SRCS = ./tests
|
|||||||
#SRCS = main42.cpp
|
#SRCS = main42.cpp
|
||||||
#SRCS = main_map_1.cpp
|
#SRCS = main_map_1.cpp
|
||||||
#SRCS = main_map_2.cpp
|
#SRCS = main_map_2.cpp
|
||||||
SRCS = main_stack_1.cpp
|
#SRCS = main_stack_1.cpp
|
||||||
#SRCS = \
|
SRCS = \
|
||||||
# main.cpp \
|
main.cpp \
|
||||||
# tests_definitions.cpp \
|
tests_definitions.cpp \
|
||||||
# \
|
\
|
||||||
# tests_vector.cpp \
|
tests_vector.cpp \
|
||||||
# tests_map.cpp \
|
tests_map.cpp \
|
||||||
# tests_stack.cpp
|
tests_stack.cpp
|
||||||
|
|
||||||
D_HEADERS = ./headers
|
D_HEADERS = ./headers
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
@@ -124,13 +124,13 @@ $(D_OBJS_STL)/%.o: %.$(EXT) | $(D_OBJS_STL)
|
|||||||
$(D_OBJS_FT) $(D_OBJS_STL):
|
$(D_OBJS_FT) $(D_OBJS_STL):
|
||||||
mkdir $@
|
mkdir $@
|
||||||
|
|
||||||
$(OBJS): $(F_INCLUDES)
|
$(OBJS_FT) $(OBJS_STL): $(F_INCLUDES)
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/19259108/makefile-same-rule-for-multiple-targets
|
# https://stackoverflow.com/questions/19259108/makefile-same-rule-for-multiple-targets
|
||||||
$(NAME_FT): $(OBJS_FT)
|
$(NAME_FT): $(OBJS_FT)
|
||||||
$(NAME_STL): $(OBJS_STL)
|
$(NAME_STL): $(OBJS_STL)
|
||||||
$(NAME_FT) $(NAME_STL):
|
$(NAME_FT) $(NAME_STL):
|
||||||
@echo $(CYAN)"linkage (link objects.o)"$(RESET)
|
@echo $(PURPLE)"linkage (link objects.o)"$(RESET)
|
||||||
@$(CC) $^ -o $@ $(LIBS)
|
@$(CC) $^ -o $@ $(LIBS)
|
||||||
|
|
||||||
leaks: leaksft
|
leaks: leaksft
|
||||||
|
|||||||
BIN
containers_ft
BIN
containers_ft
Binary file not shown.
BIN
containers_stl
Executable file
BIN
containers_stl
Executable file
Binary file not shown.
@@ -8,32 +8,13 @@ template <class InputIt1, class InputIt2>
|
|||||||
bool lexicographical_compare
|
bool lexicographical_compare
|
||||||
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2 ) {
|
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2 ) {
|
||||||
|
|
||||||
while (first1 != last1)
|
for (; first1 != last1; first1++, first2++) {
|
||||||
{
|
if (*first1 < *first2)
|
||||||
if (first2 == last2 || *first2 < *first1)
|
|
||||||
return false;
|
|
||||||
else if (*first1 < *first2)
|
|
||||||
return true;
|
return true;
|
||||||
++first1;
|
if (*first2 < *first1)
|
||||||
++first2;
|
|
||||||
}
|
|
||||||
return (first2 != last2);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class InputIt1, class InputIt2, class Compare>
|
|
||||||
bool lexicographical_compare
|
|
||||||
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) {
|
|
||||||
|
|
||||||
while (first1 != last1)
|
|
||||||
{
|
|
||||||
if (first2 == last2 || comp(*first2, *first1))
|
|
||||||
return false;
|
return false;
|
||||||
else if (comp(*first1, *first2))
|
|
||||||
return true;
|
|
||||||
++first1;
|
|
||||||
++first2;
|
|
||||||
}
|
}
|
||||||
return (first2 != last2);
|
return (first1 == last1 && first2 != last2);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ft
|
} // namespace ft
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ namespace ft {
|
|||||||
template <
|
template <
|
||||||
typename T,
|
typename T,
|
||||||
typename Container = ft::vector<T>
|
typename Container = ft::vector<T>
|
||||||
> class stack
|
> class stack {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
typedef Container container_type;
|
typedef Container container_type;
|
||||||
typedef typename Container::value_type value_type;
|
typedef typename Container::value_type value_type;
|
||||||
@@ -22,7 +22,6 @@ public:
|
|||||||
************/
|
************/
|
||||||
// constructors ------------------------------
|
// constructors ------------------------------
|
||||||
explicit stack(const container_type& cont = Container()) : c(cont) {}
|
explicit stack(const container_type& cont = Container()) : c(cont) {}
|
||||||
explicit stack(stack const &other): c(other.c) {}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -55,7 +54,7 @@ public:
|
|||||||
friend bool operator>=(const stack<T2,C2>& lhs, const stack<T2,C2>& rhs);
|
friend bool operator>=(const stack<T2,C2>& lhs, const stack<T2,C2>& rhs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Container c;
|
container_type c;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ void tests_map_relational_operators();
|
|||||||
void tests_map_swap_non_member();
|
void tests_map_swap_non_member();
|
||||||
// stack
|
// stack
|
||||||
void tests_stack_constructor();
|
void tests_stack_constructor();
|
||||||
|
void tests_stack_empty();
|
||||||
|
void tests_stack_size();
|
||||||
|
void tests_stack_top();
|
||||||
|
void tests_stack_push();
|
||||||
|
void tests_stack_pop();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
// prototypes
|
// prototypes
|
||||||
// *********************************************
|
// *********************************************
|
||||||
|
// abstract class test -----------------------
|
||||||
struct A_test
|
struct A_test
|
||||||
{
|
{
|
||||||
virtual ~A_test(){};
|
virtual ~A_test(){};
|
||||||
@@ -48,6 +49,7 @@ struct A_test
|
|||||||
std::string type;
|
std::string type;
|
||||||
virtual void func() = 0;
|
virtual void func() = 0;
|
||||||
};
|
};
|
||||||
|
// mystruct ----------------------------------
|
||||||
struct mystruct {
|
struct mystruct {
|
||||||
public:
|
public:
|
||||||
mystruct(int data = 0);
|
mystruct(int data = 0);
|
||||||
@@ -57,6 +59,7 @@ private:
|
|||||||
int * _val;
|
int * _val;
|
||||||
};
|
};
|
||||||
std::ostream & operator<<(std::ostream & o, mystruct const * rhs);
|
std::ostream & operator<<(std::ostream & o, mystruct const * rhs);
|
||||||
|
// functions ---------------------------------
|
||||||
void add_to_list(std::string title, std::string type, A_test* test);
|
void add_to_list(std::string title, std::string type, A_test* test);
|
||||||
void delete_structs();
|
void delete_structs();
|
||||||
|
|
||||||
@@ -70,17 +73,19 @@ extern std::vector< mystruct* > mem_list;
|
|||||||
// adding each test to the list
|
// adding each test to the list
|
||||||
// ***************************
|
// ***************************
|
||||||
#define TEST(f_name) TEST_V(f_name)
|
#define TEST(f_name) TEST_V(f_name)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
add_to_list(#f_name, "char", new(s_ ## f_name <char>));\
|
|
||||||
add_to_list(#f_name, "std::string", new(s_ ## f_name <std::string>));\
|
|
||||||
add_to_list(#f_name, "mystruct*", new(s_ ## f_name <mystruct*>));\
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_V(f_name) \
|
#define TEST_V(f_name) \
|
||||||
template <class T> struct s_ ## f_name : public A_test\
|
template <class T> struct s_ ## f_name : public A_test\
|
||||||
{ void func(); };\
|
{ void func(); };\
|
||||||
void f_name () {\
|
void f_name () {\
|
||||||
add_to_list("", "", NULL);\
|
add_to_list("", "", NULL);\
|
||||||
add_to_list(#f_name, "int", new(s_ ## f_name <int>));\
|
add_to_list(#f_name, "int", new(s_ ## f_name <int>));\
|
||||||
|
add_to_list(#f_name, "char", new(s_ ## f_name <char>));\
|
||||||
|
add_to_list(#f_name, "std::string", new(s_ ## f_name <std::string>));\
|
||||||
|
add_to_list(#f_name, "mystruct*", new(s_ ## f_name <mystruct*>));\
|
||||||
}\
|
}\
|
||||||
template <class T>\
|
template <class T>\
|
||||||
void s_ ## f_name <T>::func()
|
void s_ ## f_name <T>::func()
|
||||||
@@ -93,16 +98,15 @@ extern std::vector< mystruct* > mem_list;
|
|||||||
add_to_list(#f_name, "char, int", new(s_ ## f_name <char, int>));\
|
add_to_list(#f_name, "char, int", new(s_ ## f_name <char, int>));\
|
||||||
add_to_list(#f_name, "char, char", new(s_ ## f_name <char, char>));\
|
add_to_list(#f_name, "char, char", new(s_ ## f_name <char, char>));\
|
||||||
add_to_list(#f_name, "char, std::string", new(s_ ## f_name <char, std::string>));\
|
add_to_list(#f_name, "char, std::string", new(s_ ## f_name <char, std::string>));\
|
||||||
add_to_list(#f_name, "char, mystruct*", new(s_ ## f_name <char, mystruct*>));\
|
|
||||||
add_to_list(#f_name, "int, int", new(s_ ## f_name <int, int>));\
|
add_to_list(#f_name, "int, int", new(s_ ## f_name <int, int>));\
|
||||||
add_to_list(#f_name, "int, char", new(s_ ## f_name <int, char>));\
|
add_to_list(#f_name, "int, char", new(s_ ## f_name <int, char>));\
|
||||||
add_to_list(#f_name, "int, std::string", new(s_ ## f_name <int, std::string>));\
|
add_to_list(#f_name, "int, std::string", new(s_ ## f_name <int, std::string>));\
|
||||||
add_to_list(#f_name, "int, mystruct*", new(s_ ## f_name <int, mystruct*>));\
|
|
||||||
}\
|
}\
|
||||||
template <class T, class U>\
|
template <class T, class U>\
|
||||||
void s_ ## f_name <T, U>::func()
|
void s_ ## f_name <T, U>::func()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
add_to_list(#f_name, "char, mystruct*", new(s_ ## f_name <char, mystruct*>));\
|
||||||
|
add_to_list(#f_name, "int, mystruct*", new(s_ ## f_name <int, mystruct*>));\
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// templates print
|
// templates print
|
||||||
|
|||||||
133
tests/main.cpp
133
tests/main.cpp
@@ -4,87 +4,68 @@
|
|||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
// VECTOR
|
// VECTOR
|
||||||
// tests_vector_constructor();
|
tests_vector_constructor();
|
||||||
// tests_vector_operator_assignation();
|
tests_vector_operator_assignation();
|
||||||
// tests_vector_begin();
|
tests_vector_begin();
|
||||||
// tests_vector_end();
|
tests_vector_end();
|
||||||
// tests_vector_rbegin();
|
tests_vector_rbegin();
|
||||||
// tests_vector_rend();
|
tests_vector_rend();
|
||||||
// tests_vector_size();
|
tests_vector_size();
|
||||||
// tests_vector_max_size();
|
tests_vector_max_size();
|
||||||
// tests_vector_resize();
|
tests_vector_resize();
|
||||||
// tests_vector_capacity();
|
tests_vector_capacity();
|
||||||
// tests_vector_empty();
|
tests_vector_empty();
|
||||||
// tests_vector_reserve();
|
tests_vector_reserve();
|
||||||
// tests_vector_operator_access();
|
tests_vector_operator_access();
|
||||||
// tests_vector_at();
|
tests_vector_at();
|
||||||
// tests_vector_front();
|
tests_vector_front();
|
||||||
// tests_vector_back();
|
tests_vector_back();
|
||||||
// tests_vector_assign();
|
tests_vector_assign();
|
||||||
// tests_vector_push_back();
|
tests_vector_push_back();
|
||||||
// tests_vector_pop_back();
|
tests_vector_pop_back();
|
||||||
// tests_vector_insert();
|
tests_vector_insert();
|
||||||
// tests_vector_erase();
|
tests_vector_erase();
|
||||||
// tests_vector_swap();
|
tests_vector_swap();
|
||||||
// tests_vector_clear();
|
tests_vector_clear();
|
||||||
// tests_vector_get_allocator();
|
tests_vector_get_allocator();
|
||||||
// tests_vector_relational_operators();
|
tests_vector_swap_non_member();
|
||||||
// tests_vector_swap_non_member();
|
tests_vector_reverse_iterators();
|
||||||
// tests_vector_reverse_iterators();
|
tests_vector_relational_operators();
|
||||||
|
|
||||||
// MAP
|
// MAP
|
||||||
// tests_map_simple();
|
tests_map_simple();
|
||||||
// tests_map_constructor();
|
tests_map_constructor();
|
||||||
// tests_map_operator_assignation();
|
tests_map_operator_assignation();
|
||||||
// tests_map_begin();
|
tests_map_begin();
|
||||||
// tests_map_end();
|
tests_map_end();
|
||||||
// tests_map_rbegin();
|
tests_map_rbegin();
|
||||||
// tests_map_rend();
|
tests_map_rend();
|
||||||
// tests_map_empty();
|
tests_map_empty();
|
||||||
// tests_map_size();
|
tests_map_size();
|
||||||
// tests_map_max_size();
|
tests_map_max_size();
|
||||||
// tests_map_operator_access();
|
tests_map_operator_access();
|
||||||
// tests_map_insert();
|
tests_map_insert();
|
||||||
// tests_map_erase();
|
tests_map_erase();
|
||||||
// tests_map_swap();
|
tests_map_swap();
|
||||||
// tests_map_clear();
|
tests_map_clear();
|
||||||
// tests_map_key_comp();
|
tests_map_key_comp();
|
||||||
// tests_map_value_comp();
|
tests_map_value_comp();
|
||||||
// tests_map_find();
|
tests_map_find();
|
||||||
// tests_map_count();
|
tests_map_count();
|
||||||
// tests_map_lower_bound();
|
tests_map_lower_bound();
|
||||||
// tests_map_upper_bound();
|
tests_map_upper_bound();
|
||||||
// tests_map_equal_range();
|
tests_map_equal_range();
|
||||||
// tests_map_get_allocator();
|
tests_map_get_allocator();
|
||||||
// tests_map_relational_operators();
|
tests_map_swap_non_member();
|
||||||
// tests_map_swap_non_member();
|
tests_map_relational_operators();
|
||||||
|
|
||||||
|
|
||||||
// STACK
|
// STACK
|
||||||
tests_stack_constructor();
|
tests_stack_constructor();
|
||||||
// tests_stack_operator_assignation();
|
tests_stack_empty();
|
||||||
// tests_stack_begin();
|
tests_stack_size();
|
||||||
// tests_stack_end();
|
tests_stack_top();
|
||||||
// tests_stack_rbegin();
|
tests_stack_push();
|
||||||
// tests_stack_rend();
|
tests_stack_pop();
|
||||||
// tests_stack_size();
|
|
||||||
// tests_stack_max_size();
|
|
||||||
// tests_stack_resize();
|
|
||||||
// tests_stack_capacity();
|
|
||||||
// tests_stack_empty();
|
|
||||||
// tests_stack_reserve();
|
|
||||||
// tests_stack_operator_access();
|
|
||||||
// tests_stack_at();
|
|
||||||
// tests_stack_front();
|
|
||||||
// tests_stack_back();
|
|
||||||
// tests_stack_assign();
|
|
||||||
// tests_stack_push_back();
|
|
||||||
// tests_stack_pop_back();
|
|
||||||
// tests_stack_insert();
|
|
||||||
// tests_stack_erase();
|
|
||||||
// tests_stack_swap();
|
|
||||||
// tests_stack_clear();
|
|
||||||
// tests_stack_get_allocator();
|
|
||||||
|
|
||||||
// execute tests and print them :
|
// execute tests and print them :
|
||||||
int size = test_list.size();
|
int size = test_list.size();
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ TEST_DIR=$(dirname $0)
|
|||||||
OUTPUT_STL="output_stl.log"
|
OUTPUT_STL="output_stl.log"
|
||||||
OUTPUT_FT="output_ft.log"
|
OUTPUT_FT="output_ft.log"
|
||||||
|
|
||||||
make > /dev/null
|
#make -j > /dev/null
|
||||||
|
make -j
|
||||||
|
|
||||||
echo -e "\nstl :"
|
echo -e "\nstl :"
|
||||||
time ./containers_ft > tests/$OUTPUT_STL
|
time ./containers_ft > tests/$OUTPUT_STL
|
||||||
@@ -15,4 +16,4 @@ time ./containers_stl > tests/$OUTPUT_FT
|
|||||||
|
|
||||||
diff --context=0 --color=always tests/$OUTPUT_STL tests/$OUTPUT_FT
|
diff --context=0 --color=always tests/$OUTPUT_STL tests/$OUTPUT_FT
|
||||||
|
|
||||||
/bin/rm $TEST_DIR/$OUTPUT_STL $TEST_DIR/$OUTPUT_FT
|
#/bin/rm $TEST_DIR/$OUTPUT_STL $TEST_DIR/$OUTPUT_FT
|
||||||
|
|||||||
@@ -36,13 +36,10 @@ void delete_structs() {
|
|||||||
// ***********************************************
|
// ***********************************************
|
||||||
mystruct::mystruct(int data)
|
mystruct::mystruct(int data)
|
||||||
{_val = new int[2]; _val[0] = data; _val[1] = data;}
|
{_val = new int[2]; _val[0] = data; _val[1] = data;}
|
||||||
|
|
||||||
mystruct::~mystruct()
|
mystruct::~mystruct()
|
||||||
{delete[] _val;}
|
{delete[] _val;}
|
||||||
|
|
||||||
int * mystruct::get_data() const
|
int * mystruct::get_data() const
|
||||||
{return _val;}
|
{return _val;}
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & o, mystruct const * rhs) {
|
std::ostream & operator<<(std::ostream & o, mystruct const * rhs) {
|
||||||
if (rhs != NULL)
|
if (rhs != NULL)
|
||||||
o << (*rhs).get_data()[0] << "," << (*rhs).get_data()[1];
|
o << (*rhs).get_data()[0] << "," << (*rhs).get_data()[1];
|
||||||
|
|||||||
@@ -1,29 +1,135 @@
|
|||||||
|
|
||||||
#include "tests_utils.hpp"
|
#include "tests_utils.hpp"
|
||||||
|
|
||||||
|
#ifdef STL
|
||||||
|
#define DEQ_VEC deque
|
||||||
|
#else
|
||||||
|
#define DEQ_VEC vector
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(tests_stack_constructor)
|
TEST(tests_stack_constructor)
|
||||||
{
|
{
|
||||||
// title
|
// title
|
||||||
TITLE(simple test)
|
TITLE(simple test)
|
||||||
|
|
||||||
std::deque<T> mydeque (3,VAL(100)); // deque with 3 elements
|
ft::DEQ_VEC<T> mycont (2,VAL(200)); // ft::vector/stl::deque with 2 elements
|
||||||
std::vector<T> myvector (2,VAL(200)); // vector with 2 elements
|
ft::vector<T> myvector (2,VAL(200)); // vector with 2 elements
|
||||||
|
|
||||||
ft::stack<T> first; // empty stack
|
ft::stack<T> first; // empty stack
|
||||||
ft::stack<T> second (mydeque); // stack initialized to copy of deque
|
ft::stack<T> second (mycont); // stack initialized to copy of vector
|
||||||
|
|
||||||
// ft::stack< T,std::vector<T> > third; // empty stack using vector
|
ft::stack< T,ft::vector<T> > third; // empty stack using vector
|
||||||
// ft::stack< T,std::vector<T> > fourth (myvector);
|
ft::stack< T,ft::vector<T> > fourth (myvector);
|
||||||
//
|
|
||||||
// std::cout << "size of first: " << first.size() << '\n';
|
std::cout << "size of first: " << first.size() << '\n';
|
||||||
// std::cout << "size of second: " << second.size() << '\n';
|
std::cout << "size of second: " << second.size() << '\n';
|
||||||
// std::cout << "size of third: " << third.size() << '\n';
|
std::cout << "size of third: " << third.size() << '\n';
|
||||||
// std::cout << "size of fourth: " << fourth.size() << '\n';
|
std::cout << "size of fourth: " << fourth.size() << '\n';
|
||||||
//
|
|
||||||
// PRINT(first)
|
PRINT(first)
|
||||||
// PRINT(second)
|
PRINT(second)
|
||||||
// PRINT(third)
|
PRINT(third)
|
||||||
// PRINT(fourth)
|
PRINT(fourth)
|
||||||
//
|
|
||||||
// DELETE
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user