feisty meow concerns codebase
2.140
test_point.cpp
Go to the documentation of this file.
1
/*****************************************************************************\
2
* *
3
* Name : test_point *
4
* Author : Chris Koeritz *
5
* *
6
* Purpose: *
7
* *
8
* Tests out the point class. *
9
* *
10
*******************************************************************************
11
* Copyright (c) 2002-$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
19
#include <
application/hoople_main.h
>
20
#include <
basis/astring.h
>
21
#include <
basis/guards.h
>
22
#include <
geometric/point.h
>
23
#include <
loggers/console_logger.h
>
24
#include <
structures/static_memory_gremlin.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
34
class
test_point :
virtual
public
unit_base
,
virtual
public
application_shell
35
{
36
public
:
37
test_point() :
application_shell
() {}
38
DEFINE_CLASS_NAME
(
"test_point"
);
39
virtual
int
execute();
40
};
41
42
int
test_point::execute()
43
{
44
FUNCDEF
(
"execute"
);
45
{
46
// first test just instantiates some things.
47
point<double>
fred(23,
angle<double>
(4));
48
point<double>
bob(399,
angle<double>
(2.3));
49
double
dist = bob.distance(fred);
50
//LOG(astring("fred is ") + fred + " and bob is " + bob);
51
//LOG(a_sprintf("distance between is ", dist));
52
point<double>
borg(fred - bob);
53
//LOG(astring("borg is fred-bob, which is ") + borg);
54
ASSERT_FALSE
(borg.magnitude() - dist > 0.001,
55
"difference must be small between distance and magnitude"
);
56
}
57
58
{
59
astring
pt1 =
"12,38"
;
60
point<double>
to_scan;
61
to_scan.
from_text
(pt1);
62
ASSERT_FALSE
( (to_scan.
x
() != 12) || (to_scan.
y
() != 38),
63
"second test: first from_text should work"
);
64
astring
pt2 =
"{14.3,16.2989}"
;
65
to_scan.
from_text
(pt2);
66
ASSERT_FALSE
( (to_scan.
x
() != 14.3) || (to_scan.
y
() != 16.2989),
67
"second test: second from_text should work too"
);
68
}
69
70
return
final_report();
71
}
72
73
HOOPLE_MAIN
(test_point, )
74
astring.h
application::application_shell
The application_shell is a base object for console programs.
Definition:
application_shell.h:33
basis::astring
Provides a dynamically resizable ASCII character string.
Definition:
astring.h:35
geometric::angle< double >
geometric::point< double >
geometric::point::from_text
bool from_text(const basis::astring &text)
returns true if the "text" is successfully pulled into this point.
Definition:
point.h:216
geometric::point::x
numeric_type x() const
Definition:
point.h:47
geometric::point::y
numeric_type y() const
Definition:
point.h:48
unit_test::unit_base
Definition:
unit_base.h:59
console_logger.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
loggers
A logger that sends to the console screen using the standard output device.
Definition:
combo_logger.cpp:36
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
unit_base.h
ASSERT_FALSE
#define ASSERT_FALSE(a, test_name)
Definition:
unit_base.h:50
graphiq
library
tests_geometric
test_point.cpp
Generated by
1.9.1