2 * Name : test_geometry *
3 * Author : Chris Koeritz *
5 * Exercises some of the classes in the geometry library. *
7 * Copyright (c) 2001-$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 *
15 #include <application/hoople_main.h>
16 #include <basis/astring.h>
17 #include <basis/guards.h>
18 #include <geometric/cartesian_objects.h>
19 #include <geometric/circle.h>
20 #include <geometric/ellipse.h>
21 #include <geometric/line.h>
22 #include <geometric/screen_rectangle.h>
23 #include <geometric/rectangle.h>
24 #include <geometric/warper.h>
25 #include <geometric/triangle.h>
26 #include <structures/static_memory_gremlin.h>
27 #include <unit_test/unit_base.h>
29 using namespace application;
30 using namespace basis;
31 using namespace geometric;
32 using namespace loggers;
33 using namespace structures;
34 using namespace unit_test;
35 using namespace geometric;
37 class test_geometric : public virtual unit_base, public virtual application_shell
41 DEFINE_CLASS_NAME("test_geometric");
42 virtual int execute();
45 int test_geometric::execute()
51 line<double> slugmart;
52 rectangle<double> burger;
53 rectangle_warper<double> space_warp(burger, burger);
56 burger = cartesian_rectangle(23, 19, 82, 745);
57 ASSERT_TRUE(burger.from_text(astring("84.0 290.0 10.0 912.0")),
58 "cartesian from_text test should not return failure");
59 ASSERT_FALSE(burger != cartesian_rectangle(84.0, 290.0, 10.0, 912.0),
60 "cartesian from_text test should compare with expected value");
62 screen_rectangle xingu(23, 19, 82, 745);
63 ASSERT_TRUE(xingu == screen_rectangle(screen_point(23, 19), screen_point(82, 745)),
64 "xingu screen test construction should agree with expectations");
65 ASSERT_TRUE(xingu.from_text(astring("84 290 10 912")),
66 "xingu screen from_text test should not return failure");
67 ASSERT_TRUE(xingu == screen_rectangle(84, 290, 10, 912),
68 "xingu screen from_text test should compare with expected value");
70 screen_rectangle guinness(-223, 19, 82, -745);
71 ASSERT_TRUE(guinness == screen_rectangle(screen_point(-223, 19), screen_point(82, -745)),
72 "guinness screen test construction should agree with expectations");
73 ASSERT_TRUE(guinness.from_text(astring("-84 290 -10 912")),
74 "guinness screen from_text test should not return failure");
75 ASSERT_TRUE(guinness == screen_rectangle(-84, 290, -10, 912),
76 "screen from_text test should compare with expected value");
78 //log(astring(astring::SPRINTF, "the string form is %s.", guinness.text_form().s()));
80 // test non-mainstream constructors
81 // test non-mainstream constructors
87 // test class specific functions
91 return final_report();
94 HOOPLE_MAIN(test_geometric, );