1 /*******************************************************
2 * Unit test for the hour class
4 * test contrustor and assignment of hour objects
5 ******************************************************
14 // Default contructor: all zero
17 std::cout << "The default contructor makes a zero hour: \"" << h0 << "\"\n";
18 assert(h0.Hour() == 0);
19 assert(h0.Minute() == 0);
20 assert(h0.Second() == 0);
24 std::cout << "Contructor with hour = 15 minure = 20, and second = 45: \"" << h1 << "\"\n";
25 assert(h1.Hour() == 15);
26 assert(h1.Minute() == 20);
27 assert(h1.Second() == 45);
29 hour h2(88, 55, 1000);
31 std::cout << "Contructor with hour = 88 minute = 55, and second = 1000: \"" << h2 << "\"\n";
32 assert(h2.Hour() == 88);
33 assert(h2.Minute() == 55);
34 assert(h2.Second() == 1000);
36 // The copy constructor is just a bitwise copy
40 std::cout << "Copy contructor from " << h1 << ": \"" << h3 << "\"\n";
41 assert(h3.Hour() == 15);
42 assert(h3.Minute() == 20);
43 assert(h3.Second() == 45);
45 // Also assignment is just a bitwise copy
50 std::cout << "Assigned from " << h1 << ": \"" << h4 << "\"\n";
51 assert(h4.Hour() == 15);
52 assert(h4.Minute() == 20);
53 assert(h4.Second() == 45);