8a256914808f8b34521b68e3193d173ed893917b
[libacl.git] / test / hour_assign.cpp
1 /*******************************************************
2  *  Unit test for the hour class
3  *
4  * test contrustor and assignment of hour objects
5  ******************************************************
6  *
7  */
8
9 #include "date.h"
10 #include <assert.h>
11
12 int main()
13 {
14    // Default contructor: all zero
15    hour h0;
16
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);
21
22    hour h1(15, 20, 45);
23
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);
28
29    hour h2(88, 55, 1000);
30
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);
35
36    // The copy constructor is just a bitwise copy
37
38    hour h3(h1);
39
40    std::cout << "Copy contructor from " << h1 << ": \"" << h3 << "\"\n";
41    assert(h3.Hour() == 15);
42    assert(h3.Minute() == 20);
43    assert(h3.Second() == 45);
44
45    // Also assignment is just a bitwise copy
46
47    hour h4;
48
49    h4 = h1;
50    std::cout << "Assigned from " << h1 << ": \"" << h4 << "\"\n";
51    assert(h4.Hour() == 15);
52    assert(h4.Minute() == 20);
53    assert(h4.Second() == 45);
54
55    return 0;
56 }
57