1 /*****************************************************************************\
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 1995-$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 \*****************************************************************************/
15 #include <application/hoople_main.h>
16 #include <basis/guards.h>
17 #include <loggers/console_logger.h>
18 #include <loggers/critical_events.h>
19 #include <structures/set.h>
20 #include <structures/static_memory_gremlin.h>
21 #include <unit_test/unit_base.h>
23 using namespace application;
24 using namespace basis;
25 using namespace loggers;
26 using namespace mathematics;
27 using namespace structures;
28 using namespace textual;
29 using namespace timely;
30 using namespace unit_test;
32 class test_set : virtual public unit_base, virtual public application_shell
36 DEFINE_CLASS_NAME("test_set");
37 virtual int execute();
40 int test_set::execute()
44 ASSERT_TRUE(fred.empty(), "first empty check should work");
45 ASSERT_TRUE(fred.add(23), "fred 1st add should go in");
46 ASSERT_TRUE(fred.add(90123), "fred 2nd add should be okay");
47 ASSERT_FALSE(fred.add(23), "fred 3rd add works fine");
48 ASSERT_FALSE(fred.add(90123), "fred 4th add is good");
49 ASSERT_FALSE(fred.empty(), "second empty check should work");
50 ASSERT_TRUE(fred.non_empty(), "non_empty check should be right");
53 ASSERT_TRUE(gen.add(13), "gen 1st add is okay");
54 ASSERT_TRUE(gen.add(23), "gen 2nd add should be fine");
55 ASSERT_TRUE(gen.add(8012), "gen 3rd add was good");
57 int_set intersect(gen.intersection(fred));
58 ASSERT_EQUAL(intersect.elements(), 1, "intersection elements should be one");
59 ASSERT_TRUE(intersect.member(23), "element should be present as 23");
61 int_set uni(gen.set_union(fred));
62 ASSERT_EQUAL(uni.elements(), 4, "union elements should be correct");
63 ASSERT_TRUE(uni.member(23), "first element we seek should be present");
64 ASSERT_TRUE(uni.member(90123), "second element we seek should be present");
65 ASSERT_TRUE(uni.member(13), "third element we seek should be present");
66 ASSERT_TRUE(uni.member(8012), "fourth element we seek should be present");
68 return final_report();
73 HOOPLE_MAIN(test_set, )