Preparing for debian package
[ACL.git] / test / hour_parse.cpp
1 /*******************************************************
2  *  Unit test for the hour class
3  *
4  * test the date parser that converts String to hour
5  ******************************************************
6  *
7  */
8
9 #include "date.h"
10 #include <assert.h>
11
12 int main()
13 {
14    hour   h0;
15    String the_time;
16
17
18    the_time = "1134";
19    h0 = hour(the_time);
20    std::cout << "String \"" << the_time << "\" converts to: \"" << h0 << "\"\n";
21    std::cout.flush();
22    assert(h0 == hour(11, 34, 0));
23
24    the_time = "11:34";
25    h0 = hour(the_time);
26    std::cout << "String \"" << the_time << "\" converts to: \"" << h0 << "\"\n";
27    assert(h0 == hour(11, 34, 0));
28
29    the_time = "11.34";
30    h0 = hour(the_time);
31    std::cout << "String \"" << the_time << "\" converts to: \"" << h0 << "\"\n";
32    assert(h0 == hour(11, 34, 0));
33
34    the_time = "113427";
35    h0 = hour(the_time);
36    std::cout << "String \"" << the_time << "\" converts to: \"" << h0 << "\"\n";
37    assert(h0 == hour(11, 34, 27));
38
39    the_time = "11:34:27";
40    h0 = hour(the_time);
41    std::cout << "String \"" << the_time << "\" converts to: \"" << h0 << "\"\n";
42    assert(h0 == hour(11, 34, 27));
43
44    the_time = "11.34.27";
45    h0 = hour(the_time);
46    std::cout << "String \"" << the_time << "\" converts to: \"" << h0 << "\"\n";
47    assert(h0 == hour(11, 34, 27));
48
49    //  TODO: test for invalid houts and syntax errors
50
51    return 0;
52 }
53