makefile really improved on header dependencies

This commit is contained in:
hugogogo
2022-06-29 14:10:17 +02:00
parent 26436c8d8a
commit b0b63d6238
27 changed files with 610 additions and 481 deletions

View File

@@ -6,7 +6,8 @@
#include <string>
#include <iomanip> // std::setw()
#include <vector>
#include "tests_utils.hpp"
#include "tests_structs.hpp"
// global variables

View File

@@ -0,0 +1,33 @@
#ifndef TESTS_MAP_HPP
# define TESTS_MAP_HPP
#include "tests_utils.hpp"
// toogle between test ft and stl
// *************************
#ifdef STL
namespace ft = std;
#else
#include "map.hpp"
#include "reverse_iterator.hpp"
#endif
// templates print
// *****************************************
template <class T, class U>
void print(ft::map<T, U>& mp, std::string name) {
int i = 0;
typename ft::map<T, U>::iterator it;
typename ft::map<T, U>::iterator it_end = mp.end();
std::cout << "\n" << name << ":(map)\n";
for (it = mp.begin(); it != it_end; ++it, i++)
std::cout << "[" << i << "]" << it->first << ":" << it->second << " ";
std::cout << "\nsize:" << mp.size() << "\n";
}
#endif

View File

@@ -0,0 +1,28 @@
#ifndef TESTS_STACK_HPP
# define TESTS_STACK_HPP
#include "tests_utils.hpp"
// toogle between test ft and stl
// *************************
#ifdef STL
namespace ft = std;
#else
#include "stack.hpp"
#endif
// templates print
// *****************************************
template <class T, class cont>
void print(ft::stack<T,cont>& st, std::string name) {
std::cout << "\n" << name << ":(map)\n";
for (int i = st.size(); i > 0 ; i--, st.pop())
std::cout << "[" << i << "]" << st.top() << " ";
std::cout << "\nsize:" << st.size() << "\n";
}
#endif

View File

@@ -0,0 +1,24 @@
#ifndef TESTS_STRUCTS_HPP
# define TESTS_STRUCTS_HPP
// abstract class test -----------------------
struct A_test
{
virtual ~A_test(){};
std::string title;
std::string type;
virtual void func() = 0;
};
// mystruct ----------------------------------
struct mystruct {
public:
mystruct(int data = 0);
~mystruct();
int * get_data() const;
private:
int * _val;
};
std::ostream & operator<<(std::ostream & o, mystruct const * rhs);
#endif

View File

@@ -11,21 +11,11 @@
#include <utility> // std::make_pair
#include <sstream> // std::stringstream
#include <deque>
// toogle between test ft and stl
// *************************
#include <vector>
#include <map>
#include <stack>
#ifdef STL
namespace ft = std;
#else
#include "vector.hpp"
#include "map.hpp"
#include "stack.hpp"
#include "reverse_iterator.hpp"
#endif
#include "tests_structs.hpp"
// defines
@@ -41,25 +31,6 @@
// prototypes
// *********************************************
// abstract class test -----------------------
struct A_test
{
virtual ~A_test(){};
std::string title;
std::string type;
virtual void func() = 0;
};
// mystruct ----------------------------------
struct mystruct {
public:
mystruct(int data = 0);
~mystruct();
int * get_data() const;
private:
int * _val;
};
std::ostream & operator<<(std::ostream & o, mystruct const * rhs);
// functions ---------------------------------
void add_to_list(std::string title, std::string type, A_test* test);
void delete_structs();
@@ -109,40 +80,6 @@ extern std::vector< mystruct* > mem_list;
add_to_list(#f_name, "int, mystruct*", new(s_ ## f_name <int, mystruct*>));\
*/
// templates print
// *****************************************
template <class T>
void print(ft::vector<T>& vec, std::string name) {
int i = 0;
typename ft::vector<T>::iterator it;
typename ft::vector<T>::iterator it_end = vec.end();
std::cout << "\n" << name << ":(vector)\n";
for (it = vec.begin(); it != it_end; ++it, i++)
std::cout << "[" << i << "]" << *it << " ";
std::cout << "\nsize:" << vec.size() << " capacty:" << vec.capacity() << "\n";
}
template <class T, class U>
void print(ft::map<T, U>& mp, std::string name) {
int i = 0;
typename ft::map<T, U>::iterator it;
typename ft::map<T, U>::iterator it_end = mp.end();
std::cout << "\n" << name << ":(map)\n";
for (it = mp.begin(); it != it_end; ++it, i++)
std::cout << "[" << i << "]" << it->first << ":" << it->second << " ";
std::cout << "\nsize:" << mp.size() << "\n";
}
template <class T, class cont>
void print(ft::stack<T,cont>& st, std::string name) {
std::cout << "\n" << name << ":(map)\n";
for (int i = st.size(); i > 0 ; i--, st.pop())
std::cout << "[" << i << "]" << st.top() << " ";
std::cout << "\nsize:" << st.size() << "\n";
}
// templates get value
// *************************************

View File

@@ -0,0 +1,33 @@
#ifndef TESTS_VECTOR_HPP
# define TESTS_VECTOR_HPP
#include "tests_utils.hpp"
// toogle between test ft and stl
// *************************
#ifdef STL
namespace ft = std;
#else
#include "vector.hpp"
#include "reverse_iterator.hpp"
#endif
// templates print
// *****************************************
template <class T>
void print(ft::vector<T>& vec, std::string name) {
int i = 0;
typename ft::vector<T>::iterator it;
typename ft::vector<T>::iterator it_end = vec.end();
std::cout << "\n" << name << ":(vector)\n";
for (it = vec.begin(); it != it_end; ++it, i++)
std::cout << "[" << i << "]" << *it << " ";
std::cout << "\nsize:" << vec.size() << " capacty:" << vec.capacity() << "\n";
}
#endif

View File

@@ -4,68 +4,68 @@
int main() {
// VECTOR
tests_vector_constructor();
tests_vector_operator_assignation();
tests_vector_begin();
tests_vector_end();
tests_vector_rbegin();
tests_vector_rend();
tests_vector_size();
tests_vector_max_size();
tests_vector_resize();
tests_vector_capacity();
tests_vector_empty();
tests_vector_reserve();
tests_vector_operator_access();
tests_vector_at();
tests_vector_front();
tests_vector_back();
tests_vector_assign();
tests_vector_push_back();
tests_vector_pop_back();
tests_vector_insert();
tests_vector_erase();
tests_vector_swap();
tests_vector_clear();
tests_vector_get_allocator();
tests_vector_swap_non_member();
tests_vector_reverse_iterators();
tests_vector_relational_operators();
// tests_vector_constructor();
// tests_vector_operator_assignation();
// tests_vector_begin();
// tests_vector_end();
// tests_vector_rbegin();
// tests_vector_rend();
// tests_vector_size();
// tests_vector_max_size();
// tests_vector_resize();
// tests_vector_capacity();
// tests_vector_empty();
// tests_vector_reserve();
// tests_vector_operator_access();
// tests_vector_at();
// tests_vector_front();
// tests_vector_back();
// tests_vector_assign();
// tests_vector_push_back();
// tests_vector_pop_back();
// tests_vector_insert();
// tests_vector_erase();
// tests_vector_swap();
// tests_vector_clear();
// tests_vector_get_allocator();
// tests_vector_swap_non_member();
// tests_vector_reverse_iterators();
// tests_vector_relational_operators();
// MAP
tests_map_simple();
tests_map_constructor();
tests_map_operator_assignation();
tests_map_begin();
tests_map_end();
tests_map_rbegin();
tests_map_rend();
tests_map_empty();
tests_map_size();
tests_map_max_size();
tests_map_operator_access();
// tests_map_simple();
// tests_map_constructor();
// tests_map_operator_assignation();
// tests_map_begin();
// tests_map_end();
// tests_map_rbegin();
// tests_map_rend();
// tests_map_empty();
// tests_map_size();
// tests_map_max_size();
// tests_map_operator_access();
tests_map_insert();
tests_map_erase();
tests_map_swap();
tests_map_clear();
tests_map_key_comp();
tests_map_value_comp();
tests_map_find();
tests_map_count();
tests_map_lower_bound();
tests_map_upper_bound();
tests_map_equal_range();
tests_map_get_allocator();
tests_map_swap_non_member();
tests_map_relational_operators();
// tests_map_swap();
// tests_map_clear();
// tests_map_key_comp();
// tests_map_value_comp();
// tests_map_find();
// tests_map_count();
// tests_map_lower_bound();
// tests_map_upper_bound();
// tests_map_equal_range();
// tests_map_get_allocator();
// tests_map_swap_non_member();
// tests_map_relational_operators();
// STACK
tests_stack_constructor();
tests_stack_empty();
tests_stack_size();
tests_stack_top();
tests_stack_push();
tests_stack_pop();
// tests_stack_constructor();
// tests_stack_empty();
// tests_stack_size();
// tests_stack_top();
// tests_stack_push();
// tests_stack_pop();
// execute tests and print them :
int size = test_list.size();

View File

@@ -1,5 +1,6 @@
#include "tests_utils.hpp"
#include "tests_map.hpp"
/**/ // UTILS for some tests
/**/ bool fncomp (char lhs, char rhs) {return lhs<rhs;}

View File

@@ -1,5 +1,5 @@
#include "tests_utils.hpp"
#include "tests_stack.hpp"
#ifdef STL
#define DEQ_VEC deque

View File

@@ -1,5 +1,6 @@
#include "tests_utils.hpp"
#include "tests_vector.hpp"
TEST_V(tests_vector_constructor)
{