From 3074f7c93c10f0d80cf946055a38c5c90d6ff6b7 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sun, 19 Jun 2022 12:33:18 +0200 Subject: [PATCH] tests for map ope --- tests/includes/tests_utils.hpp | 16 +++++++++- tests/tests_map.cpp | 14 ++++----- tests/tests_vector.cpp | 54 +++++++++++++++++----------------- 3 files changed, 49 insertions(+), 35 deletions(-) diff --git a/tests/includes/tests_utils.hpp b/tests/includes/tests_utils.hpp index 7060d81..77aabb7 100644 --- a/tests/includes/tests_utils.hpp +++ b/tests/includes/tests_utils.hpp @@ -28,6 +28,8 @@ // **************************************** # define TITLE(s) std::cout << "\n" B_PURPLE #s RESET "\n\n"; # define VAL(n) val(n) +# define VALT(n) val(n) +# define VALU(n) val(n) # define TOI(n) toi(n) # define PRINT(n) print(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 struct s_ ## f_name : public A_test\ { void func(); };\ void f_name () {\ @@ -75,6 +77,18 @@ extern std::vector< mystruct* > mem_list; template \ void s_ ## f_name ::func() +#define TEST_M(f_name) \ + template struct s_ ## f_name : public A_test\ + { void func(); };\ + void f_name () {\ + add_to_list(#f_name, "int, int", new(s_ ## f_name ));\ + add_to_list("", "char, int", new(s_ ## f_name ));\ + add_to_list("", "std::string, int", new(s_ ## f_name ));\ + add_to_list("", "mystruct*, int", new(s_ ## f_name ));\ + }\ + template \ + void s_ ## f_name ::func() + // templates print // ***************************************** diff --git a/tests/tests_map.cpp b/tests/tests_map.cpp index c096902..6cfb0ee 100644 --- a/tests/tests_map.cpp +++ b/tests/tests_map.cpp @@ -4,18 +4,18 @@ #include "tests_utils.hpp" -TEST(tests_map_simple) +TEST_M(tests_map_simple) { // title TITLE(simple test) - typename std::map first; - typename std::map::iterator it; + typename std::map first; + typename std::map::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'; diff --git a/tests/tests_vector.cpp b/tests/tests_vector.cpp index 6bc1f02..86a73d7 100644 --- a/tests/tests_vector.cpp +++ b/tests/tests_vector.cpp @@ -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::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)