feisty meow concerns codebase
2.140
test_angle.cpp
Go to the documentation of this file.
1
/*
2
* Name : test_angle *
3
* Author : Chris Koeritz *
4
* Purpose: *
5
* Tests the angle class. *
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 <
geometric/angle.h
>
18
#include <
loggers/program_wide_logger.h
>
19
#include <
mathematics/double_plus.h
>
20
#include <
structures/static_memory_gremlin.h
>
21
#include <
unit_test/unit_base.h
>
22
23
using namespace
application
;
24
using namespace
basis
;
25
using namespace
geometric
;
26
using namespace
loggers
;
27
using namespace
mathematics
;
28
using namespace
structures
;
29
using namespace
unit_test
;
30
31
typedef
double_plus
floot
;
32
33
class
test_angle :
public
virtual
unit_base
,
public
virtual
application_shell
34
{
35
public
:
36
test_angle() :
application_shell
() {}
37
DEFINE_CLASS_NAME
(
"test_angle"
);
38
virtual
int
execute();
39
};
40
41
int
test_angle::execute()
42
{
43
FUNCDEF
(
"execute"
);
44
{
45
// first test group: double angle inverse trigonometrics.
46
angle<double>
a(30.3,
DEGREES
);
47
ASSERT_EQUAL
(
floot
(a.get(
RADIANS
)),
floot
(.528835),
"radian conversion should be right"
);
48
49
outcome
retval;
50
angle<double>
at =
angle<double>::arctangent
(28.3, 29.5, retval);
51
ASSERT_EQUAL
(
floot
(at.
get
(
DEGREES
)),
floot
(43.8106),
"atan should be what we expect"
);
52
angle<double>
as =
angle<double>::arcsine
(17.6, 82.3, retval);
53
ASSERT_EQUAL
(
floot
(as.
get
(
DEGREES
)),
floot
(12.3482),
"asin should be what we expect"
);
54
angle<double>
ac =
angle<double>::arccosine
(17.2, 42.0, retval);
55
ASSERT_EQUAL
(
floot
(ac.
get
(
DEGREES
)),
floot
(65.8251),
"acos should be what we expect"
);
56
}
57
{
58
// second test: packing an angle.
59
angle<double>
q(128,
DEGREES
);
60
byte_array
pacd;
61
int
siz = q.packed_size();
62
q.pack(pacd);
63
ASSERT_EQUAL
(siz, pacd.
length
(),
"packed size should report proper length"
);
64
angle<double>
x;
65
x.
unpack
(pacd);
66
ASSERT_EQUAL
(
floot
(q.get(
RADIANS
)),
floot
(x.
get
(
RADIANS
)),
67
"unpacking should return original value"
);
68
ASSERT_FALSE
(pacd.
length
(),
"unpacking should consume entire array"
);
69
}
70
71
return
final_report();
72
}
73
75
76
HOOPLE_MAIN
(test_angle, )
77
angle.h
astring.h
application::application_shell
The application_shell is a base object for console programs.
Definition:
application_shell.h:33
basis::array::length
int length() const
Returns the current reported length of the allocated C array.
Definition:
array.h:115
basis::byte_array
A very common template for a dynamic array of bytes.
Definition:
byte_array.h:36
basis::outcome
Outcomes describe the state of completion for an operation.
Definition:
outcome.h:31
geometric::angle< double >
geometric::angle::get
contents get(angular_units unit) const
retrieves the current angular measure.
Definition:
angle.h:202
geometric::angle::unpack
virtual bool unpack(basis::byte_array &packed_form)
unpacks the angle from the "packed_form".
Definition:
angle.h:174
mathematics::double_plus
Definition:
double_plus.h:37
unit_test::unit_base
Definition:
unit_base.h:59
double_plus.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
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
geometric::RADIANS
@ RADIANS
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
program_wide_logger.h
static_memory_gremlin.h
floot
double_plus floot
Definition:
test_angle.cpp:31
unit_base.h
ASSERT_EQUAL
#define ASSERT_EQUAL(a, b, test_name)
Definition:
unit_base.h:38
ASSERT_FALSE
#define ASSERT_FALSE(a, test_name)
Definition:
unit_base.h:50
graphiq
library
tests_geometric
test_angle.cpp
Generated by
1.9.1