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