Added date class
[ACL.git] / test / date_assign.cpp
1 /*******************************************************
2  *  Unit test for the date class
3  *
4  * test contrustor and assignment of Sting objects
5  ******************************************************
6  *
7  */
8
9 #include "date.h"
10 #include <assert.h>
11
12 int main()
13 {
14    // Default contructor: all zero
15    date d0;
16
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);
21
22    // Constructors with default arguments
23    date d1(5);
24
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);
29
30    date d2(10, 7);
31
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);
36
37    date d3(15, 9, 2002);
38
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);
43
44    date d4(88, 55, 1000);
45
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);
50
51    // The copy constructor is just a bitwise copy
52
53    date d5(d3);
54
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);
59
60    // Also assignment is just a bitwise copy
61
62    date d6;
63
64    d6 = d3;
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);
69
70    return 0;
71 }
72