feisty meow concerns codebase
2.140
test_ellipse.cpp
Go to the documentation of this file.
1
/*
2
* Name : test_ellipse *
3
* Author : Chris Koeritz *
4
* Purpose: *
5
* Tests the ellipse class. *
6
**
7
* Copyright (c) 1993-$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/ellipse.h
>
20
#include <
geometric/point.h
>
21
#include <
mathematics/double_plus.h
>
22
#include <
structures/static_memory_gremlin.h
>
23
#include <
unit_test/unit_base.h
>
24
25
using namespace
application
;
26
using namespace
basis
;
27
using namespace
geometric
;
28
using namespace
loggers
;
29
using namespace
mathematics
;
30
using namespace
structures
;
31
using namespace
unit_test
;
32
33
typedef
cartesian_point
e_point
;
34
35
class
test_ellipse :
virtual
public
unit_base
,
virtual
public
application_shell
36
{
37
public
:
38
test_ellipse() :
application_shell
() {}
39
DEFINE_CLASS_NAME
(
"test_ellipse"
);
40
int
execute();
41
point<double>
supposed_good_value(
const
angle<double>
&rotation);
42
};
43
44
point<double>
test_ellipse::supposed_good_value(
const
angle<double>
&rotation)
45
{
46
double_plus
rot(rotation.
get
(
DEGREES
));
47
//log(a_sprintf("rotation coming in is %f", rot.value()));
48
if
(rot ==
double_plus
(0.0))
return
point<double>
(25.000000, 20.0000);
49
if
(rot ==
double_plus
(35.3))
return
point<double>
(24.7134, 23.3372);
50
if
(rot ==
double_plus
(70.6))
return
point<double>
(22.8791, 28.1757);
51
if
(rot ==
double_plus
(105.9))
return
point<double>
(17.5249, 11.3112);
52
if
(rot ==
double_plus
(141.2))
return
point<double>
(15.3608, 16.2700);
53
if
(rot ==
double_plus
(176.5))
return
point<double>
(15.0023, 19.6943);
54
if
(rot ==
double_plus
(211.8))
return
point<double>
(15.2242, 22.9611);
55
if
(rot ==
double_plus
(247.1))
return
point<double>
(16.7732, 27.6388);
56
if
(rot ==
double_plus
(282.4))
return
point<double>
(22.0127, 10.8459);
57
if
(rot ==
double_plus
(317.7))
return
point<double>
(24.5511, 15.8588);
58
if
(rot ==
double_plus
(353.0))
return
point<double>
(24.9906, 19.3872);
59
return
point<double>
(0, 0);
// unknown angle.
60
}
61
62
int
test_ellipse::execute()
63
{
64
FUNCDEF
(
"execute"
);
65
ellipse
fred(
e_point
(20, 20), 5, 10);
66
for
(
double
i = 0; i < 360.0; i += 35.3) {
67
e_point
where(fred.location(
double_angle
(i,
DEGREES
)));
68
a_sprintf
test_name
(
"%.2f"
,
double_angle
(i,
DEGREES
).get(
DEGREES
));
69
// log(astring(astring::SPRINTF, "at angle %f ellipse is at ", i) + where.text_form());
70
point<double>
compare = supposed_good_value(
double_angle
(i,
DEGREES
));
71
// right now point is not orderable, so we compare x and y but use the same test name.
72
ASSERT_EQUAL
(
double_plus
(where.x()),
double_plus
(compare.
x
()),
73
test_name
+
" rotation should have proper position"
);
74
ASSERT_EQUAL
(
double_plus
(where.y()),
double_plus
(compare.
y
()),
75
test_name
+
" rotation should have proper position"
);
76
}
77
return
final_report();
78
}
79
81
82
HOOPLE_MAIN
(test_ellipse, )
83
astring.h
cartesian_objects.h
application::application_shell
The application_shell is a base object for console programs.
Definition:
application_shell.h:33
basis::a_sprintf
a_sprintf is a specialization of astring that provides printf style support.
Definition:
astring.h:440
geometric::angle< double >
geometric::angle::get
contents get(angular_units unit) const
retrieves the current angular measure.
Definition:
angle.h:202
geometric::cartesian_point
Provides a geometric point that use double floating points numbers.
Definition:
cartesian_objects.h:28
geometric::double_angle
double_angle provides a non-templated class for forward declarations.
Definition:
angle.h:97
geometric::ellipse
Represents a geometric ellipse.
Definition:
ellipse.h:28
geometric::point< double >
geometric::point::x
numeric_type x() const
Definition:
point.h:47
geometric::point::y
numeric_type y() const
Definition:
point.h:48
mathematics::double_plus
Definition:
double_plus.h:37
unit_test::unit_base
Definition:
unit_base.h:59
double_plus.h
ellipse.h
DEFINE_CLASS_NAME
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition:
enhance_cpp.h:45
FUNCDEF
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition:
enhance_cpp.h:57
guards.h
hoople_main.h
Provides macros that implement the 'main' program of an application.
HOOPLE_MAIN
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition:
hoople_main.h:61
application
Implements an application lock to ensure only one is running at once.
Definition:
application_shell.cpp:40
basis
The guards collection helps in testing preconditions and reporting errors.
Definition:
array.h:30
geometric
Contains all of our objects for geometry and avoids name clashes.
Definition:
angle.h:25
geometric::DEGREES
@ DEGREES
Definition:
angle.h:30
loggers
A logger that sends to the console screen using the standard output device.
Definition:
combo_logger.cpp:36
mathematics
An extension to floating point primitives providing approximate equality.
Definition:
averager.h:21
structures
A dynamic container class that holds any kind of object via pointers.
Definition:
amorph.h:55
unit_test
Useful support functions for unit testing, especially within hoople.
Definition:
unit_base.cpp:35
point.h
static_memory_gremlin.h
e_point
cartesian_point e_point
Definition:
test_ellipse.cpp:33
test_name
#define test_name()
unit_base.h
ASSERT_EQUAL
#define ASSERT_EQUAL(a, b, test_name)
Definition:
unit_base.h:38
graphiq
library
tests_geometric
test_ellipse.cpp
Generated by
1.9.1