1 /*******************************************************
2 * Unit test for the date class
4 * test contrustor and assignment of Sting objects
5 ******************************************************
14 // Default contructor: all zero
17 std::cout << "The default contructor makes a zero date: \"" << d0 << "\"\n";
18 assert(d0.Day() == 0);
19 assert(d0.Month() == 0);
20 assert(d0.Year() == 0);
22 // Constructors with default arguments
25 std::cout << "Contructor with just day = 5: \"" << d1 << "\"\n";
26 assert(d1.Day() == 5);
27 assert(d1.Month() == 0);
28 assert(d1.Year() == 0);
32 std::cout << "Contructor with just day = 10 and month = 7: \"" << d2 << "\"\n";
33 assert(d2.Day() == 10);
34 assert(d2.Month() == 7);
35 assert(d2.Year() == 0);
39 std::cout << "Contructor with day = 15 month = 9, and year = 2002: \"" << d3 << "\"\n";
40 assert(d3.Day() == 15);
41 assert(d3.Month() == 9);
42 assert(d3.Year() == 2002);
44 date d4(88, 55, 1000);
46 std::cout << "Contructor with day = 88 month = 55, and year = 1000: \"" << d4 << "\"\n";
47 assert(d4.Day() == 88);
48 assert(d4.Month() == 55);
49 assert(d4.Year() == 1000);
51 // The copy constructor is just a bitwise copy
55 std::cout << "Copy contructor from day = 15 month = 9, and year = 2002: \"" << d5 << "\"\n";
56 assert(d5.Day() == 15);
57 assert(d5.Month() == 9);
58 assert(d5.Year() == 2002);
60 // Also assignment is just a bitwise copy
65 std::cout << "Assigned from day = 15 month = 9, and year = 2002: \"" << d6 << "\"\n";
66 assert(d6.Day() == 15);
67 assert(d6.Month() == 9);
68 assert(d6.Year() == 2002);