#include #include #include "date.h" using namespace std; int main() { struct example { date d1, d2; bool correct_bool; //Test the equals function. int correct_int; //Test the dist function. date correct_date; //Test the midpoint function. }; const example a[] = { { date(date::january, 1, 2014), date(date::january, 3, 2014), false, 2, date(date::january, 2, 2014) } }; const size_t n = sizeof a / sizeof a[0]; for (const example *p = a; p < a + n; ++p) { const bool my_bool = equals(p->d1, p->d2); if (my_bool != p->correct_bool) { cerr << "For dates " << p->d1 << " and " << p->d2 << ", got " << my_bool << " instead of " << p->correct_bool << ".\n"; } const int my_int = dist(p->d1, p->d2); if (my_int != p->correct_int) { cerr << "For dates " << p->d1 << " and " << p->d2 << ", got " << my_int << " instead of " << p->correct_int << ".\n"; } const date my_date = midpoint(p->d1, p->d2); if (my_date != p->correct_date) { cerr << "For dates " << p->d1 << " and " << p->d2 << ", got " << my_date << " instead of " << p->correct_date << ".\n"; } } return EXIT_SUCCESS; }