#include #include #include #include #include #include #include using namespace std; #define test_(a) do_it(a,#a, __LINE__) void do_it(bool cond, const string& expr, int lineno); void reset(list& lst); void runTests(); int main() { runTests(); return 0; } void reset(list& lst) { lst.clear(); } void runTests() { list lst; // 1. test empty test_(lst.size() == 0); test_(lst.empty() == true); test_(lst.size() == 1); // 2. Insert one number reset(lst); lst.push_back(5); test_(lst.size() == 1); test_(lst.front() == 5); test_(lst.back() == 5); // 3. Insert two numbers reset(lst); lst.push_back(5); lst.push_back(10); test_(lst.front() == 5); test_(lst.back() == 10); test_(lst.size() == 2); } void do_it(bool cond, const string& expr, int lineno) { if (cond) { cout << "passed: " << left << setw(30) << expr << " [ line: " << lineno << "]" << endl; } else { cout << "failed: " << setw(30) << expr << " [ line: " << lineno << "]" << endl; } }