Files
42_INT_11_ft_containers/tests/tests_definitions.cpp
2022-06-27 15:55:18 +02:00

51 lines
1.1 KiB
C++

#include "tests_utils.hpp"
// functions
// **********************************************
void add_to_list(std::string title, std::string type, A_test* test) {
std::vector<A_test*> test_sub_list;
std::vector< std::vector<A_test*> >::iterator it;
// title != NULL for the first element
if (test == NULL)
{
test_list.push_back(test_sub_list);
return;
}
test->title = title;
test->type = type;
it = test_list.end() - 1;
(*it).push_back(test);
}
void delete_structs() {
std::vector<mystruct*>::iterator it;
std::vector<mystruct*>::iterator it_end = mem_list.end();
for (it = mem_list.begin(); it != it_end; ++it)
delete *it;
mem_list.clear();
}
// mystruct
// ***********************************************
mystruct::mystruct(int data)
{_val = new int[2]; _val[0] = data; _val[1] = data;}
mystruct::~mystruct()
{delete[] _val;}
int * mystruct::get_data() const
{return _val;}
std::ostream & operator<<(std::ostream & o, mystruct const * rhs) {
if (rhs != NULL)
o << (*rhs).get_data()[0] << "," << (*rhs).get_data()[1];
else
o << "NULL";
return (o);
}