d08 ex00 ok
This commit is contained in:
58
d08/ex00/main.cpp
Normal file
58
d08/ex00/main.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "colors.h"
|
||||
|
||||
#include "easyfind.hpp"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#define N_TEST "3"
|
||||
|
||||
template < typename T >
|
||||
void standardTest(T container) {
|
||||
typename T::const_iterator it;
|
||||
int test;
|
||||
|
||||
for (int i = -9 ; i < 10 ; i++)
|
||||
container.push_back(i);
|
||||
for (it = container.begin(); it != container.end(); it++)
|
||||
std::cout << *it << ": " << &*it << "\n";
|
||||
std::cout << "\n";
|
||||
test = -3;
|
||||
try {
|
||||
it = easyfind(container, test);
|
||||
std::cout << *it << ": " << &*it << "\n";
|
||||
}
|
||||
catch (std::exception const & e) {
|
||||
std::cout << test << ": " << e.what() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int i = 0;
|
||||
|
||||
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
||||
<< "tests list :" RESET "\n";
|
||||
{
|
||||
std::list<int> container;
|
||||
standardTest(container);
|
||||
}
|
||||
|
||||
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
||||
<< "tests vector :" RESET "\n";
|
||||
{
|
||||
std::vector<int> container;
|
||||
standardTest(container);
|
||||
}
|
||||
|
||||
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
||||
<< "tests deque :" RESET "\n";
|
||||
{
|
||||
std::deque<int> container;
|
||||
standardTest(container);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user