feisty meow concerns codebase  2.140
test_version.cpp
Go to the documentation of this file.
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 
14 #include <basis/astring.h>
15 #include <basis/functions.h>
16 #include <basis/guards.h>
17 #include <loggers/console_logger.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 
The application_shell is a base object for console programs.
Holds a file's version identifier.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition: enhance_cpp.h:45
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition: enhance_cpp.h:57
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition: hoople_main.h:61
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
A platform independent way to obtain the timestamp of a file.
Definition: byte_filer.cpp:37
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
Definition: averager.h:21
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55
#include <time.h>
Definition: earth_time.cpp:37
Useful support functions for unit testing, especially within hoople.
Definition: unit_base.cpp:35
#define ASSERT_TRUE(a, test_name)
Definition: unit_base.h:46
#define ASSERT_FALSE(a, test_name)
Definition: unit_base.h:50