push
This commit is contained in:
+30
-10
@@ -9,24 +9,44 @@ int main()
|
||||
vec.push_back(42);
|
||||
vec.push_back(56);
|
||||
vec.push_back(87);
|
||||
std::cout << "Test vector container" << std::endl << "Find 42 (pos 2)" << std::endl;
|
||||
std::vector<int>::iterator it = easyfind(vec, 42);
|
||||
std::cout << "Find " << *it << std::endl;
|
||||
|
||||
std::list<int> lst;
|
||||
lst.push_back(10);
|
||||
lst.push_back(47);
|
||||
lst.push_back(42);
|
||||
lst.push_back(87);
|
||||
std::cout << "Test list container" << std::endl << "Find 42 (pos 3)" << std::endl;
|
||||
std::list<int>::iterator it2 = easyfind(lst, 42);
|
||||
std::cout << "Find " << *it2 << std::endl;
|
||||
|
||||
std::cout << "Test vector container" << std::endl << "Find 41 (not here !)" << std::endl;
|
||||
std::cout << "--- TEST 1 : vector, search 10 (present) ---" << std::endl;
|
||||
try {
|
||||
std::vector<int>::iterator it3 = easyfind(vec, 41);
|
||||
std::cout << "found " << *it3 << std::endl;
|
||||
std::vector<int>::iterator it = easyfind(vec, 10);
|
||||
std::cout << "Found : " << *it << std::endl;
|
||||
} catch (std::exception &e) {
|
||||
std::cout << "Exeption catch : not found !" << std::endl;
|
||||
std::cout << "Exception : " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "--- TEST 2 : list, search 42 (present) ---" << std::endl;
|
||||
try {
|
||||
std::list<int>::iterator it = easyfind(lst, 42);
|
||||
std::cout << "Found : " << *it << std::endl;
|
||||
} catch (std::exception &e) {
|
||||
std::cout << "Exception : " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "--- TEST 3 : vector, search 41 (not present) ---" << std::endl;
|
||||
try {
|
||||
std::vector<int>::iterator it = easyfind(vec, 41);
|
||||
std::cout << "Found : " << *it << std::endl;
|
||||
} catch (std::exception &e) {
|
||||
std::cout << "Exception : " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "--- TEST 4 : list, search 99 (not present) ---" << std::endl;
|
||||
try {
|
||||
std::list<int>::iterator it = easyfind(lst, 99);
|
||||
std::cout << "Found : " << *it << std::endl;
|
||||
} catch (std::exception &e) {
|
||||
std::cout << "Exception : " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user