d08 ex00 ajout tests cha
This commit is contained in:
BIN
d08/ex00/easyfind
Executable file
BIN
d08/ex00/easyfind
Executable file
Binary file not shown.
@@ -10,22 +10,20 @@
|
|||||||
#define N_TEST "3"
|
#define N_TEST "3"
|
||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
void standardTest(T container) {
|
void standardTest(T container, int test) {
|
||||||
typename T::const_iterator it;
|
typename T::const_iterator it;
|
||||||
int test;
|
|
||||||
|
|
||||||
for (int i = -9 ; i < 10 ; i++)
|
for (int i = 65 ; i < 91 ; i++)
|
||||||
container.push_back(i);
|
container.push_back(i);
|
||||||
for (it = container.begin(); it != container.end(); it++)
|
for (it = container.begin(); it != container.end(); it++)
|
||||||
std::cout << *it << ": " << &*it << "\n";
|
std::cout << *it << ": " << &*it << "\n";
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
test = -3;
|
|
||||||
try {
|
try {
|
||||||
it = easyfind(container, test);
|
it = easyfind(container, test);
|
||||||
std::cout << *it << ": " << &*it << "\n";
|
std::cout << *it << ": " << &*it << "\n\n";
|
||||||
}
|
}
|
||||||
catch (std::exception const & e) {
|
catch (std::exception const & e) {
|
||||||
std::cout << test << ": " << e.what() << "\n";
|
std::cout << test << ": " << e.what() << "\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,21 +34,27 @@ int main() {
|
|||||||
<< "tests list :" RESET "\n";
|
<< "tests list :" RESET "\n";
|
||||||
{
|
{
|
||||||
std::list<int> container;
|
std::list<int> container;
|
||||||
standardTest(container);
|
standardTest(container, 70);
|
||||||
|
std::list<char> container2;
|
||||||
|
standardTest(container2, 'T');
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
||||||
<< "tests vector :" RESET "\n";
|
<< "tests vector :" RESET "\n";
|
||||||
{
|
{
|
||||||
std::vector<int> container;
|
std::vector<int> container;
|
||||||
standardTest(container);
|
standardTest(container, 70);
|
||||||
|
std::vector<char> container2;
|
||||||
|
standardTest(container2, 'T');
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
|
||||||
<< "tests deque :" RESET "\n";
|
<< "tests deque :" RESET "\n";
|
||||||
{
|
{
|
||||||
std::deque<int> container;
|
std::deque<int> container;
|
||||||
standardTest(container);
|
standardTest(container, 70);
|
||||||
|
std::deque<char> container2;
|
||||||
|
standardTest(container2, 'T');
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user