feisty meow concerns codebase  2.140
test_geometry.cpp
Go to the documentation of this file.
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 
16 #include <basis/astring.h>
17 #include <basis/guards.h>
19 #include <geometric/circle.h>
20 #include <geometric/ellipse.h>
21 #include <geometric/line.h>
23 #include <geometric/rectangle.h>
24 #include <geometric/warper.h>
25 #include <geometric/triangle.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 
The application_shell is a base object for console programs.
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
Provides a geometric rectangle that use double floating points numbers.
Represents a geometric circle.
Definition: circle.h:29
Represents a geometric ellipse.
Definition: ellipse.h:28
bool from_text(const basis::astring &text)
Returns true if the "text" is parsed into this rectangle.
Definition: rectangle.h:359
a simple class used to describe points on a graphics screen.
Represents a rectangle as interpreted on display screens.
Represents a geometric triangle.
Definition: triangle.h:29
#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.
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
Contains all of our objects for geometry and avoids name clashes.
Definition: angle.h:25
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55
Useful support functions for unit testing, especially within hoople.
Definition: unit_base.cpp:35
HOOPLE_MAIN(test_geometric,)
#define ASSERT_TRUE(a, test_name)
Definition: unit_base.h:46
#define ASSERT_FALSE(a, test_name)
Definition: unit_base.h:50