tests are receving as much argument as necessary, and print works with map

This commit is contained in:
hugogogo
2022-06-19 11:49:49 +02:00
parent 94745ca8a9
commit 50224fb432
8 changed files with 40 additions and 165 deletions

View File

@@ -29,7 +29,7 @@
# define TITLE(s) std::cout << "\n" B_PURPLE #s RESET "\n\n";
# define VAL(n) val<T>(n)
# define TOI(n) toi<T>(n)
# define PRINT(n) print_vector<T>(n);
# define PRINT(n) print<T>(n);
# define DELETE delete_structs();
@@ -51,7 +51,7 @@ private:
int * _val;
};
std::ostream & operator<<(std::ostream & o, mystruct const * rhs);
void add_to_list(std::string s, A_test* s1, A_test* s2, A_test* s3, A_test* s4);
void add_to_list(std::string title, std::string type, A_test* test);
void delete_structs();
@@ -66,14 +66,12 @@ extern std::vector< mystruct* > mem_list;
#define TEST(f_name) \
template <class T> struct s_ ## f_name : public A_test\
{ void func(); };\
void f_name ()\
{ add_to_list(\
#f_name,\
new(s_ ## f_name <int>),\
new(s_ ## f_name <char>),\
new(s_ ## f_name <std::string>),\
new(s_ ## f_name <mystruct*>)\
);}\
void f_name () {\
add_to_list(#f_name, "int", new(s_ ## f_name <int>));\
add_to_list("", "char", new(s_ ## f_name <char>));\
add_to_list("", "std::string", new(s_ ## f_name <std::string>));\
add_to_list("", "mystruct*", new(s_ ## f_name <mystruct*>));\
}\
template <class T>\
void s_ ## f_name <T>::func()
@@ -81,7 +79,7 @@ extern std::vector< mystruct* > mem_list;
// templates print
// *****************************************
template <class T>
void print_vector(ft::vector<T> vec) {
void print(ft::vector<T> vec) {
int i = 0;
typename ft::vector<T>::iterator it;
@@ -91,6 +89,17 @@ template <class T>
std::cout << "[" << i << "]" << *it << " ";
std::cout << "\nsize:" << vec.size() << " capacty:" << vec.capacity() << "\n";
}
template <class T, class U>
void print(ft::map<T, U> ma) {
int i = 0;
typename ft::map<T, U>::iterator it;
typename ft::map<T, U>::iterator it_end = ma.end();
for (it = ma.begin(); it != it_end; ++it, i++)
std::cout << "[" << i << "]" << it->first << ":" << it->second << " ";
std::cout << "\nsize:" << ma.size() << "\n";
}
// templates get value
// *************************************