#ifndef LISTTEST_HPP #define LISTTEST_HPP #include "../../list/list.hpp" /* ************************************************************************** */ template void InsertAtFront(uint& testnum, uint& testerr, lasd::List& lst, bool chk, const Data& val) { bool tst; testnum++; try { std::cout << " " << testnum << " Insert at the front of the list the value \"" << val << "\": "; lst.InsertAtFront(val); std::cout << ((tst = chk) ? "Correct" : "Error") << "!" << std::endl; } catch(std::exception exc) { std::cout << "\"" << exc.what() << "\": " << ((tst = !chk) ? "Correct" : "Error") << "!" << std::endl; } testerr += (1 - (uint) tst); } template void RemoveFromFront(uint& testnum, uint& testerr, lasd::List& lst, bool chk) { bool tst; testnum++; try { std::cout << " " << testnum << " Remove from the list of \"" << lst.Front() << "\": "; lst.RemoveFromFront(); std::cout << ((tst = chk) ? "Correct" : "Error") << "!" << std::endl; } catch(std::length_error exc) { std::cout << exc.what() << "\": " << ((tst = !chk) ? "Correct" : "Error") << "!" << std::endl; } testerr += (1 - (uint) tst); } template void FrontNRemove(uint& testnum, uint& testerr, lasd::List& lst, bool chk, const Data& val) { bool tst; testnum++; try { std::cout << " " << testnum << " FrontNRemove from the list of \"" << lst.Front() << "\": "; std::cout << ((tst = ((lst.FrontNRemove() == val) == chk)) ? "Correct" : "Error") << "!" << std::endl; } catch(std::length_error exc) { std::cout << exc.what() << "\": " << ((tst = !chk) ? "Correct" : "Error") << "!" << std::endl; } testerr += (1 - (uint) tst); } template void InsertAtBack(uint& testnum, uint& testerr, lasd::List& lst, bool chk, const Data& val) { bool tst; testnum++; try { std::cout << " " << testnum << " Insert at the back of the list the value \"" << val << "\": "; lst.InsertAtBack(val); std::cout << ((tst = chk) ? "Correct" : "Error") << "!" << std::endl; } catch(std::exception exc) { std::cout << "\"" << exc.what() << "\": " << ((tst = !chk) ? "Correct" : "Error") << "!" << std::endl; } testerr += (1 - (uint) tst); } template void EqualList(uint& testnum, uint& testerr, const lasd::List& lst1, const lasd::List& lst2, bool chk) { bool tst; testnum++; try { std::cout << " " << testnum << " The two lists are " << ((tst = (lst1 == lst2)) ? "" : "not ") << "equal: "; std::cout << ((tst = (tst == chk)) ? "Correct" : "Error") << "!" << std::endl; } catch(std::exception exc) { std::cout << "\"" << exc.what() << "\": " << ((tst = !chk) ? "Correct" : "Error") << "!" << std::endl; } testerr += (1 - (uint) tst); } template void NonEqualList(uint& testnum, uint& testerr, const lasd::List& lst1, const lasd::List& lst2, bool chk) { bool tst; testnum++; try { std::cout << " " << testnum << " The two lists are " << ((tst = (lst1 != lst2)) ? "not " : "") << "equal: "; std::cout << ((tst = (tst == chk)) ? "Correct" : "Error") << "!" << std::endl; } catch(std::exception exc) { std::cout << "\"" << exc.what() << "\": " << ((tst = !chk) ? "Correct" : "Error") << "!" << std::endl; } testerr += (1 - (uint) tst); } /* ************************************************************************** */ #endif