Skip to content

Commit

Permalink
deceiving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RidaEn-nasry committed Oct 24, 2022
1 parent c1b6a83 commit f3194dd
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 245 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
"program": "/Users/wa5ina/42/Reimplementing-STL-Containers./test",
"program": "/Users/ren-nasr/Reimplementing-STL-Containers./test",
"args": [
"main"
"benchmark"
],
"cwd": "${cwd}",

Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ CONTAINERS=-I./containers/
TESTS=./tests/vector.cpp\
./tests/test.cpp\
./tests/iterator_traits.cpp\
./tests/reverse_iterator.cpp\
./tests/stack.cpp\
./tests/enable_if.cpp\
./tests/pair.cpp\
Expand Down
Empty file removed tests/AVL.cpp
Empty file.
414 changes: 225 additions & 189 deletions tests/benchmarking.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/enable_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 11:42:52 by ren-nasr #+# #+# */
/* Updated: 2022/10/08 22:12:53 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:48:11 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -22,5 +22,6 @@ void ft_enable_if_tests_suite()
REQUIRE_EQ(a, 1, test_name, "enable_if<true, int>::type should be int");
REQUIRE_STREQ(typeid(ft::enable_if<true, int>::type).name(), typeid(int).name(), test_name, "enable_if<true, int>::type should be of type int");
INFO_OK(test_name);
//sleep(1);
}
}
6 changes: 3 additions & 3 deletions tests/equal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 22:21:47 by ren-nasr #+# #+# */
/* Updated: 2022/10/08 22:25:10 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:48:07 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -32,6 +32,7 @@ void ft_equal_tests_suite() {
a[5] = 4;
REQUIRE_EQ(ft::equal(a.begin(), a.end(), b.begin()), false, test_name, "equal should return false if the two sequences are not equal");
INFO_OK(test_name);
//sleep(1);
}

/*** predicate ***/
Expand All @@ -52,8 +53,7 @@ void ft_equal_tests_suite() {
a[5] = 4;
REQUIRE_EQ(ft::equal(a.begin(), a.end(), b.begin(), std::equal_to<int>()), false, test_name, "equal should return false if the two sequences are not equal");
INFO_OK(test_name);


//sleep(1);
}

};
3 changes: 2 additions & 1 deletion tests/is_integral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 22:11:11 by ren-nasr #+# #+# */
/* Updated: 2022/10/08 22:16:46 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:48:00 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,6 +45,7 @@ void ft_is_integral_tests_suite() {
REQUIRE_EQ(ft::is_integral<unsigned int>::value, true, test_name, "is_integral<unsigned int>::value should be true");
REQUIRE_EQ(ft::is_integral<unsigned long long int>::value, true, test_name, "is_integral<unsigned long long int>::value should be true");
INFO_OK(test_name);
//sleep(1);
}

};
1 change: 1 addition & 0 deletions tests/iterator_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void ft_iterator_traits_tests_suite() {
REQUIRE_STREQ(typeid(ft::iterator_traits<const int*>::reference).name(), typeid(const int&).name(), test_name, "iterator_traits<const pointer>::reference should be of type const int&");

INFO_OK(test_name);
//sleep(1);
}
}

4 changes: 3 additions & 1 deletion tests/lexico_compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 21:48:04 by ren-nasr #+# #+# */
/* Updated: 2022/10/08 22:04:10 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:47:38 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -31,6 +31,7 @@ void ft_lexico_compare_tests_suite()
a[5] = 4;
REQUIRE_EQ(ft::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()), true, test_name, "lexicographical_compare should return true if the first sequence is less than the second");
INFO_OK(test_name);
//sleep(1);
};

/*********************************************************/
Expand All @@ -51,6 +52,7 @@ void ft_lexico_compare_tests_suite()
a[5] = 4;
REQUIRE_EQ(ft::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), ft::less<int>()), true, test_name, "lexicographical_compare should return true if the first sequence is less than the second");
INFO_OK(test_name);
//sleep(1);
};

};
11 changes: 10 additions & 1 deletion tests/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/19 19:15:17 by ren-nasr #+# #+# */
/* Updated: 2022/10/24 18:22:01 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:47:23 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -38,6 +38,7 @@ void ft_map_tests_suite()
REQUIRE_EQ(typeid(ft::map<std::vector<char>, std::string>::difference_type), typeid(std::ptrdiff_t), test_name, "`difference_type` member types is missing or invalid");
REQUIRE_EQ(typeid(ft::map<std::vector<char>, std::string>::size_type), typeid(std::size_t), test_name, "`size_type` member types is missing or invalid");
INFO_OK(test_name);
//sleep(1);
}

/******************************************************************************/
Expand Down Expand Up @@ -109,6 +110,7 @@ void ft_map_tests_suite()
REQUIRE_EQ(a, m5.get_allocator(), test_name, "`get_allocator()` member function should return the same value as it's copy ctor");

INFO_OK(test_name);
//sleep(1);
}


Expand Down Expand Up @@ -138,6 +140,7 @@ void ft_map_tests_suite()
++it;
}
INFO_OK(test_name);
//sleep(1);
}


Expand All @@ -161,6 +164,7 @@ void ft_map_tests_suite()
ft::map<int, int>::size_type max_size = m1.get_allocator().max_size();
REQUIRE_EQ(max_size, m1.max_size(), test_name, "`max_size()` member function should return the same value as std::map");
INFO_OK(test_name);
//sleep(1);
}

/******************************************************************************/
Expand Down Expand Up @@ -294,6 +298,7 @@ void ft_map_tests_suite()
REQUIRE_EQ(m4.empty(), m5.empty(), test_name, "`swap()` member function should swap the map");

INFO_OK(test_name);
//sleep(1);
}

/* ************************************************************************** */
Expand Down Expand Up @@ -336,6 +341,7 @@ void ft_map_tests_suite()
REQUIRE_EQ(p2.second->first, 2, test_name, "`equal_range()` member function should return the iterator to the element if found");

INFO_OK(test_name);
//sleep(1);
}

/* ************************************************************************** */
Expand Down Expand Up @@ -380,6 +386,7 @@ void ft_map_tests_suite()
}

INFO_OK(test_name);
//sleep(1);
}

/* ************************************************************************** */
Expand All @@ -405,6 +412,7 @@ void ft_map_tests_suite()
REQUIRE_EQ(vc(p2, p2), false, test_name, "`value_comp()` member function should return the value comparison object");

INFO_OK(test_name);
//sleep(1);
}
/* ************************************************************************** */
/* non-member functions */
Expand Down Expand Up @@ -477,5 +485,6 @@ void ft_map_tests_suite()
REQUIRE_EQ(m4[i], i, test_name, "`swap` non-member function should swap the contents of the two maps");
}
INFO_OK(test_name);
//sleep(1);
}
}
5 changes: 4 additions & 1 deletion tests/pair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 17:31:19 by ren-nasr #+# #+# */
/* Updated: 2022/10/08 18:23:05 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:47:12 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -27,6 +27,7 @@ void ft_pair_tests_suite() {
REQUIRE_STREQ(typeid(a).name(), typeid(int).name(), test_name, "first_type should be of type int");
REQUIRE_STREQ(typeid(b).name(), typeid(char).name(), test_name, "second_type should be of type char");
INFO_OK(test_name);
//sleep(1);
}

/* ************************************************************************** */
Expand Down Expand Up @@ -58,6 +59,7 @@ void ft_pair_tests_suite() {
REQUIRE_EQ(c.first, 1, test_name, "operator= should initialize first to other.first, `first = other.first`");
REQUIRE_EQ(c.second, 'a', test_name, "operator= should initialize second to other.second, `second = other.second`");
INFO_OK(test_name);
//sleep(1);
}
// free(test_name);
// relational operators
Expand All @@ -75,6 +77,7 @@ void ft_pair_tests_suite() {
REQUIRE_GE(a, b, test_name, "operator>= should return true if `first` is greater than `first` of other");
REQUIRE_LE(a, b, test_name, "operator<= should return true if `first` is less than `first` of other");
INFO_OK(test_name);
//sleep(1);
}


Expand Down
32 changes: 0 additions & 32 deletions tests/reverse_iterator.cpp

This file was deleted.

5 changes: 4 additions & 1 deletion tests/stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void ft_stack_tests_suite() {
REQUIRE_STREQ(typeid(ft_size).name(), typeid(size_t).name(), test_name, "`ft::stack` should use `size_t` as default size type");
REQUIRE_STREQ(typeid(ft_value).name(), typeid(int).name(), test_name, "`ft::stack` should use `T` as default value type");
INFO_OK(test_name);
//sleep(1);
}

/*****************************************************************************/
Expand Down Expand Up @@ -86,6 +87,7 @@ void ft_stack_tests_suite() {
REQUIRE(ft_stack.empty(), test_name, "pop() should remove the top element of the stack");

INFO_OK(test_name);
//sleep(1);
}

// /***************************************************************************/
Expand All @@ -100,6 +102,7 @@ void ft_stack_tests_suite() {
REQUIRE_EQ(ft_stack.size(), (size_t)1, test_name, "ft::stack should be compatabile with std::vector");
REQUIRE_EQ(ft_stack.top(), v, test_name, "ft::stack should be compatabile with std::vector");

INFO_OK(test_name);
INFO_OK(test_name);
//sleep(1);
}
};
9 changes: 3 additions & 6 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ren-nasr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/30 11:49:06 by ren-nasr #+# #+# */
/* Updated: 2022/10/24 18:10:58 by ren-nasr ### ########.fr */
/* Updated: 2022/10/24 20:42:48 by ren-nasr ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,7 +21,7 @@ void ft_run_all_tests()
ft_enable_if_tests_suite();
ft_is_integral_tests_suite();
ft_equal_tests_suite();
ft_avlnode_tests_suite();

ft_map_tests_suite();
ft_benchmarking_tests_suite();
}
Expand All @@ -45,8 +45,6 @@ int main(int argc, char** argv)
ft_run_all_tests();
else if (strcmp(argv[1], "vector") == 0)
ft_vector_tests_suite();
else if (strcmp(argv[1], "reverse_iterator") == 0)
ft_reverse_iterator_tests_suite();
else if (strcmp(argv[1], "enable_if") == 0)
ft_enable_if_tests_suite();
else if (strcmp(argv[1], "pair") == 0)
Expand All @@ -59,8 +57,7 @@ int main(int argc, char** argv)
ft_is_integral_tests_suite();
else if (strcmp(argv[1], "equal") == 0)
ft_equal_tests_suite();
else if (strcmp(argv[1], "avlnode") == 0)
ft_avlnode_tests_suite();

else if (strcmp(argv[1], "map") == 0)
ft_map_tests_suite();
else if (strcmp(argv[1], "benchmark") == 0)
Expand Down
6 changes: 5 additions & 1 deletion tests/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#include <sys/wait.h>
#include <typeinfo>

#define VEC_TEST_SIZE 3
#define MAP_TEST_SIZE 3
#define STACK_TEST_SIZE 3

#define INFO_ERR() std::cout << "\033[31m[ERROR]\033[0m " << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "(): " << std::endl;
#define INFO_OK(test_name) std::cout << "\033[1;34m" << test_name << "\033[0m" \
<< "\033[1;32m" \
Expand Down Expand Up @@ -157,7 +161,7 @@
void ft_vector_tests_suite();
void ft_stack_tests_suite();
void ft_iterator_traits_tests_suite();
void ft_reverse_iterator_tests_suite();

void ft_enable_if_tests_suite();
void ft_pair_tests_suite();
void ft_lexico_compare_tests_suite();
Expand Down
Loading

0 comments on commit f3194dd

Please sign in to comment.