first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / tests_structures / test_version.cpp
1 /*
2 *  Name   : test_version
3 *  Author : Chris Koeritz
4 **
5 * Copyright (c) 2009-$now By Author.  This program is free software; you can  *
6 * redistribute it and/or modify it under the terms of the GNU General Public  *
7 * License as published by the Free Software Foundation; either version 2 of   *
8 * the License or (at your option) any later version.  This is online at:      *
9 *     http://www.fsf.org/copyleft/gpl.html                                    *
10 * Please send any updates to: fred@gruntose.com                               *
11 */
12
13 #include <application/hoople_main.h>
14 #include <basis/astring.h>
15 #include <basis/functions.h>
16 #include <basis/guards.h>
17 #include <loggers/console_logger.h>
18 #include <loggers/critical_events.h>
19 #include <structures/static_memory_gremlin.h>
20 #include <structures/version_record.h>
21 #include <unit_test/unit_base.h>
22
23 using namespace application;
24 using namespace basis;
25 using namespace filesystem;
26 using namespace loggers;
27 using namespace mathematics;
28 using namespace structures;
29 using namespace textual;
30 using namespace timely;
31 using namespace unit_test;
32
33 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
34
35 class test_version : public virtual unit_base, virtual public application_shell
36 {
37 public:
38   test_version() : application_shell() {}
39   DEFINE_CLASS_NAME("test_version");
40   virtual int execute();
41 };
42
43 int test_version::execute()
44 {
45   FUNCDEF("execute");
46
47   version v1(5, 6, 138);
48   version v2(5, 7, 108);
49   ASSERT_TRUE((v1 < v2), "compare v1 < v2 should work properly");
50   ASSERT_FALSE(v1 > v2, "compare v1 > v2 should work properly");
51   ASSERT_FALSE(v1 == v2, "compare v1 == v2 should work properly");
52   ASSERT_TRUE((v1 != v2), "compare v1 != v2 should work properly");
53
54   version v3(4, 6, 180);
55   ASSERT_TRUE((v3 < v1), "compare v3 < v1 should work properly");
56   ASSERT_FALSE(v3 > v1, "compare v3 > v1 should work properly");
57   ASSERT_FALSE(v3 == v1, "compare v3 == v1 should work properly");
58   ASSERT_TRUE((v3 != v1), "compare v3 != v1 should work properly");
59   ASSERT_TRUE((v3 < v2), "compare v3 < v2 should work properly");
60   ASSERT_FALSE(v3 > v2, "compare v3 > v2 should work properly");
61   ASSERT_FALSE(v3 == v2, "compare v3 == v2 should work properly");
62   ASSERT_TRUE((v3 != v2), "compare v3 != v2 should work properly");
63   ASSERT_FALSE(v1 < v3, "compare v1 < v3 should work properly");
64   ASSERT_TRUE((v1 > v3), "compare v1 > v3 should work properly");
65   ASSERT_FALSE(v1 == v3, "compare v1 == v3 should work properly");
66   ASSERT_TRUE((v1 != v3), "compare v1 != v3 should work properly");
67   ASSERT_FALSE(v2 < v3, "compare v2 < v3 should work properly");
68   ASSERT_TRUE((v2 > v3), "compare v2 > v3 should work properly");
69   ASSERT_FALSE(v2 == v3, "compare v2 == v3 should work properly");
70   ASSERT_TRUE((v2 != v3), "compare v2 != v3 should work properly");
71
72   version v4(4, 6, 180);
73   ASSERT_FALSE(v3 < v4, "compare v3 < v4 should work properly");
74   ASSERT_FALSE(v3 > v4, "compare v3 > v4 should work properly");
75   ASSERT_TRUE((v3 == v4), "compare v3 == v4 should work properly");
76   ASSERT_FALSE(v3 != v4, "compare v3 != v4 should work properly");
77   ASSERT_FALSE(v4 < v3, "compare v4 < v3 should work properly");
78   ASSERT_FALSE(v4 > v3, "compare v4 > v3 should work properly");
79   ASSERT_TRUE((v4 == v3), "compare v4 == v3 should work properly");
80   ASSERT_FALSE(v4 != v3, "compare v4 != v3 should work properly");
81
82   return final_report();
83 }
84
85 HOOPLE_MAIN(test_version, )
86