first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / graphiq / library / tests_geometric / test_geometry.cpp
1 /*
2 *  Name   : test_geometry                                                     *
3 *  Author : Chris Koeritz                                                     *
4 *  Purpose:                                                                   *
5 *    Exercises some of the classes in the geometry library.                   *
6 **
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                               *
13 */
14
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>
28
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;
36
37 class test_geometric : public virtual unit_base, public virtual application_shell
38 {
39 public:
40   test_geometric() {}
41   DEFINE_CLASS_NAME("test_geometric");
42   virtual int execute();
43 };
44
45 int test_geometric::execute()
46 {
47   FUNCDEF("execute");
48   // test constructors
49   circle fred;
50   ellipse tobias;
51   line<double> slugmart;
52   rectangle<double> burger;
53   rectangle_warper<double> space_warp(burger, burger);
54   triangle euclid;
55
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");
61
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");
69
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");
77
78 //log(astring(astring::SPRINTF, "the string form is %s.", guinness.text_form().s()));
79
80   // test non-mainstream constructors
81   // test non-mainstream constructors
82
83   // test operators
84
85   // test conversions
86
87   // test class specific functions
88
89   // test other things?
90
91   return final_report();
92 }
93
94 HOOPLE_MAIN(test_geometric, );
95