tests for map ope

This commit is contained in:
hugogogo
2022-06-19 12:33:18 +02:00
parent 50224fb432
commit 3074f7c93c
3 changed files with 49 additions and 35 deletions

View File

@@ -28,6 +28,8 @@
// ****************************************
# define TITLE(s) std::cout << "\n" B_PURPLE #s RESET "\n\n";
# define VAL(n) val<T>(n)
# define VALT(n) val<T>(n)
# define VALU(n) val<U>(n)
# define TOI(n) toi<T>(n)
# define PRINT(n) print<T>(n);
# define DELETE delete_structs();
@@ -63,7 +65,7 @@ extern std::vector< mystruct* > mem_list;
// adding each test to the list
// ***************************
#define TEST(f_name) \
#define TEST_V(f_name) \
template <class T> struct s_ ## f_name : public A_test\
{ void func(); };\
void f_name () {\
@@ -75,6 +77,18 @@ extern std::vector< mystruct* > mem_list;
template <class T>\
void s_ ## f_name <T>::func()
#define TEST_M(f_name) \
template <class T, class U> struct s_ ## f_name : public A_test\
{ void func(); };\
void f_name () {\
add_to_list(#f_name, "int, int", new(s_ ## f_name <int, int>));\
add_to_list("", "char, int", new(s_ ## f_name <char, int>));\
add_to_list("", "std::string, int", new(s_ ## f_name <std::string, int>));\
add_to_list("", "mystruct*, int", new(s_ ## f_name <mystruct*, int>));\
}\
template <class T, class U>\
void s_ ## f_name <T, U>::func()
// templates print
// *****************************************

View File

@@ -4,18 +4,18 @@
#include "tests_utils.hpp"
TEST(tests_map_simple)
TEST_M(tests_map_simple)
{
// title
TITLE(simple test)
typename std::map<T, int> first;
typename std::map<T, int>::iterator it;
typename std::map<T, U> first;
typename std::map<T, U>::iterator it;
first[VAL('a')]=10;
first[VAL('b')]=30;
first[VAL('c')]=50;
first[VAL('d')]=70;
first[VALT('a')]=VALU(10);
first[VALT('b')]=VALU(30);
first[VALT('c')]=VALU(50);
first[VALT('d')]=VALU(70);
for(it=first.begin(); it!=first.end(); ++it){
std::cout << it->first << " => " << it->second << '\n';

View File

@@ -4,7 +4,7 @@
#include "tests_utils.hpp"
TEST(tests_vector_constructor)
TEST_V(tests_vector_constructor)
{
// title
TITLE(cplusplus.com reference)
@@ -24,7 +24,7 @@ TEST(tests_vector_constructor)
DELETE
}
TEST(tests_vector_operator_assignation)
TEST_V(tests_vector_operator_assignation)
{
// title
TITLE(cplusplus.com reference)
@@ -51,7 +51,7 @@ TEST(tests_vector_operator_assignation)
DELETE
}
TEST(tests_vector_begin)
TEST_V(tests_vector_begin)
{
// title
TITLE(cplusplus.com reference :)
@@ -65,7 +65,7 @@ TEST(tests_vector_begin)
DELETE
}
TEST(tests_vector_end)
TEST_V(tests_vector_end)
{
// title
TITLE(cplusplus.com reference :)
@@ -79,7 +79,7 @@ TEST(tests_vector_end)
DELETE
}
TEST(tests_vector_rbegin)
TEST_V(tests_vector_rbegin)
{
// title
TITLE(cplusplus.com reference :)
@@ -98,7 +98,7 @@ TEST(tests_vector_rbegin)
DELETE
}
TEST(tests_vector_rend)
TEST_V(tests_vector_rend)
{
// title
TITLE(cplusplus.com reference :)
@@ -117,7 +117,7 @@ TEST(tests_vector_rend)
DELETE
}
TEST(tests_vector_size)
TEST_V(tests_vector_size)
{
// title
TITLE(cplusplus.com reference :)
@@ -139,7 +139,7 @@ TEST(tests_vector_size)
DELETE
}
TEST(tests_vector_max_size)
TEST_V(tests_vector_max_size)
{
// title
TITLE(cplusplus.com reference :)
@@ -158,7 +158,7 @@ TEST(tests_vector_max_size)
DELETE
}
TEST(tests_vector_resize)
TEST_V(tests_vector_resize)
{
// title
TITLE(cplusplus.com reference :)
@@ -242,7 +242,7 @@ TEST(tests_vector_resize)
DELETE
}
TEST(tests_vector_capacity)
TEST_V(tests_vector_capacity)
{
// title
TITLE(cplusplus.com reference :)
@@ -259,7 +259,7 @@ TEST(tests_vector_capacity)
DELETE
}
TEST(tests_vector_empty)
TEST_V(tests_vector_empty)
{
// title
TITLE(cplusplus.com reference :)
@@ -280,7 +280,7 @@ TEST(tests_vector_empty)
DELETE
}
TEST(tests_vector_reserve)
TEST_V(tests_vector_reserve)
{
// title
TITLE(cplusplus.com reference :)
@@ -314,7 +314,7 @@ TEST(tests_vector_reserve)
DELETE
}
TEST(tests_vector_operator_access)
TEST_V(tests_vector_operator_access)
{
// title
TITLE(cplusplus.com reference :)
@@ -340,7 +340,7 @@ TEST(tests_vector_operator_access)
DELETE
}
TEST(tests_vector_at)
TEST_V(tests_vector_at)
{
// title
TITLE(cplusplus.com reference :)
@@ -357,7 +357,7 @@ TEST(tests_vector_at)
DELETE
}
TEST(tests_vector_front)
TEST_V(tests_vector_front)
{
// title
TITLE(cplusplus.com reference :)
@@ -378,7 +378,7 @@ TEST(tests_vector_front)
DELETE
}
TEST(tests_vector_back)
TEST_V(tests_vector_back)
{
// title
TITLE(cplusplus.com reference :)
@@ -397,7 +397,7 @@ TEST(tests_vector_back)
DELETE
}
TEST(tests_vector_assign)
TEST_V(tests_vector_assign)
{
// title
TITLE(cplusplus.com reference :)
@@ -466,7 +466,7 @@ TEST(tests_vector_assign)
DELETE
}
TEST(tests_vector_push_back)
TEST_V(tests_vector_push_back)
{
// title
TITLE(cplusplus.com reference :)
@@ -498,7 +498,7 @@ TEST(tests_vector_push_back)
DELETE
}
TEST(tests_vector_pop_back)
TEST_V(tests_vector_pop_back)
{
// title
TITLE(cplusplus.com reference :)
@@ -529,7 +529,7 @@ TEST(tests_vector_pop_back)
DELETE
}
TEST(tests_vector_insert)
TEST_V(tests_vector_insert)
{
typename ft::vector<T>::iterator it;
@@ -615,7 +615,7 @@ TEST(tests_vector_insert)
DELETE
}
TEST(tests_vector_erase)
TEST_V(tests_vector_erase)
{
// title
TITLE(cplusplus.com reference :)
@@ -656,7 +656,7 @@ TEST(tests_vector_erase)
DELETE
}
TEST(tests_vector_swap)
TEST_V(tests_vector_swap)
{
// title
TITLE(cplusplus.com reference :)
@@ -675,7 +675,7 @@ TEST(tests_vector_swap)
DELETE
}
TEST(tests_vector_clear)
TEST_V(tests_vector_clear)
{
// title
TITLE(cplusplus.com reference :)
@@ -698,7 +698,7 @@ TEST(tests_vector_clear)
DELETE
}
TEST(tests_vector_get_allocator)
TEST_V(tests_vector_get_allocator)
{
// title
TITLE(cplusplus.com reference :)
@@ -724,7 +724,7 @@ TEST(tests_vector_get_allocator)
DELETE
}
TEST(tests_vector_relational_operators)
TEST_V(tests_vector_relational_operators)
{
// title
TITLE(cplusplus.com reference :)
@@ -742,7 +742,7 @@ TEST(tests_vector_relational_operators)
DELETE
}
TEST(tests_vector_swap_non_member)
TEST_V(tests_vector_swap_non_member)
{
// title
TITLE(cplusplus.com reference :)
@@ -761,7 +761,7 @@ TEST(tests_vector_swap_non_member)
DELETE
}
TEST(tests_vector_reverse_iterators)
TEST_V(tests_vector_reverse_iterators)
{
// title
TITLE(cplusplus.com reference)