feisty meow concerns codebase  2.140
test_warper.cpp
Go to the documentation of this file.
1 /*****************************************************************************\
2 * *
3 * Name : test_rectangle_warper *
4 * Author : Chris Koeritz *
5 * *
6 * Purpose: *
7 * *
8 * Tests the rectangle warper class. *
9 * *
10 *******************************************************************************
11 * Copyright (c) 1993-$now By Author. This program is free software; you can *
12 * redistribute it and/or modify it under the terms of the GNU General Public *
13 * License as published by the Free Software Foundation; either version 2 of *
14 * the License or (at your option) any later version. This is online at: *
15 * http://www.fsf.org/copyleft/gpl.html *
16 * Please send any updates to: fred@gruntose.com *
17 \*****************************************************************************/
18 
20 #include <basis/astring.h>
21 #include <basis/functions.h>
22 #include <basis/guards.h>
23 #include <geometric/warper.h>
25 #include <unit_test/unit_base.h>
26 
27 using namespace application;
28 using namespace basis;
29 using namespace geometric;
30 using namespace loggers;
31 using namespace structures;
32 using namespace unit_test;
33 using namespace geometric;
34 
35 class test_rectangle_warper : public virtual unit_base, virtual public application_shell
36 {
37 public:
38  test_rectangle_warper() {}
39  DEFINE_CLASS_NAME("test_rectangle_warper");
40  virtual int execute();
41 };
42 
43 int test_rectangle_warper::execute()
44 {
45  FUNCDEF("execute");
46  rectangle<double> inner(-20, 0, -60, 30);
47  rectangle<double> outer(20, 30, 0, 0);
50 //LOG(astring("inner to outer warper is: " + ito.text_form()));
51 
52  rectangle<double> warped_inner(ito.to_system_2(inner));
53 //LOG(astring("warped inner becomes ") + warped_inner.text_form());
54  rectangle<double> warped_outer(ito.to_system_1(outer));
55 //LOG(astring(" and outer becomes ") + warped_outer.text_form());
56  ASSERT_FALSE( (warped_inner != outer) || (warped_outer != inner),
57  "systems should warp to each other correctly");
58 
59  point<double> in_center(inner.center());
60  point<double> warp_in_center(ito.to_system_2(in_center));
61  point<double> out_center(outer.center());
62  point<double> warp_out_center(ito.to_system_1(out_center));
63  ASSERT_FALSE( (warp_out_center != inner.center()) || (warp_in_center != outer.center()),
64  "centers should warp to each other");
65  return final_report();
66 }
67 
68 HOOPLE_MAIN(test_rectangle_warper, );
69 
The application_shell is a base object for console programs.
#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_rectangle_warper,)
#define ASSERT_FALSE(a, test_name)
Definition: unit_base.h:50