return compare(h) == 0;
}
+ bool operator!=(hour h)
+ {
+ return compare(h) != 0;
+ }
+
+ bool operator<(hour h)
+ {
+ return compare(h) < 0;
+ }
+
+ bool operator>(hour h)
+ {
+ return compare(h) > 0;
+ }
+
+ bool operator<=(hour h)
+ {
+ return compare(h) <= 0;
+ }
+
+ bool operator>=(hour h)
+ {
+ return compare(h) >= 0;
+ }
+
friend hour operator+(hour &, hour &);
hour operator += (hour h);
friend hour operator-(hour &, hour &);
LDADD = ../src/.libs/libACL.la
check_PROGRAMS = string_assign string_basics string_compare string_cat string_substring string_regex \
date_assign date_parse date_compare date_arithmetic date_attributes date_check_today \
- hour_assign hour_parse
+ hour_assign hour_parse hour_compare
string_assign_SOURCES = string_assign.cpp
string_basics_SOURCES = string_basics.cpp
hour_assign_SOURCES = hour_assign.cpp
hour_parse_SOURCES = hour_parse.cpp
+hour_compare_SOURCES = hour_compare.cpp
--- /dev/null
+/*******************************************************
+ * Unit test for the hour class
+ *
+ * test hour relational operators
+ ******************************************************
+ *
+ */
+
+#include "date.h"
+#include <assert.h>
+
+int main()
+{
+ hour h0(9, 20, 45);
+ hour h1(9, 20, 45);
+ hour h2(15,10, 40);
+
+ // equal dates
+
+ std::cout << h0 << " == " << h1 << " = " << (h0 == h1) << "\n";
+ assert((h0 == h1) == true);
+
+ std::cout << h0 << " != " << h1 << " = " << (h0 != h1) << "\n";
+ assert((h0 != h1) == false);
+
+ std::cout << h0 << " < " << h1 << " = " << (h0 < h1) << "\n";
+ assert((h0 < h1) == false);
+
+ std::cout << h0 << " <= " << h1 << " = " << (h0 <= h1) << "\n";
+ assert((h0 <= h1) == true);
+
+ std::cout << h0 << " > " << h1 << " = " << (h0 > h1) << "\n";
+ assert((h0 > h1) == false);
+
+ std::cout << h0 << " >= " << h1 << " = " << (h0 >= h1) << "\n";
+ assert((h0 >= h1) == true);
+
+ // unequal dates
+
+ std::cout << h0 << " == " << h2 << " = " << (h0 == h2) << "\n";
+ assert((h0 == h2) == false);
+
+ std::cout << h0 << " != " << h2 << " = " << (h0 != h2) << "\n";
+ assert((h0 != h2) == true);
+
+ std::cout << h0 << " < " << h2 << " = " << (h0 < h2) << "\n";
+ assert((h0 < h2) == true);
+
+ std::cout << h0 << " <= " << h2 << " = " << (h0 <= h2) << "\n";
+ assert((h0 <= h2) == true);
+
+ std::cout << h0 << " > " << h2 << " = " << (h0 > h2) << "\n";
+ assert((h0 > h2) == false);
+
+ std::cout << h0 << " >= " << h2 << " = " << (h0 >= h2) << "\n";
+ assert((h0 >= h2) == false);
+
+ return 0;
+}
+
--- /dev/null
+09:20:45 == 09:20:45 = 1
+09:20:45 != 09:20:45 = 0
+09:20:45 < 09:20:45 = 0
+09:20:45 <= 09:20:45 = 1
+09:20:45 > 09:20:45 = 0
+09:20:45 >= 09:20:45 = 1
+09:20:45 == 15:10:40 = 0
+09:20:45 != 15:10:40 = 1
+09:20:45 < 15:10:40 = 1
+09:20:45 <= 15:10:40 = 1
+09:20:45 > 15:10:40 = 0
+09:20:45 >= 15:10:40 = 0
+PASS hour_compare (exit status: 0)