feisty meow concerns codebase
2.140
test_double_plus.cpp
Go to the documentation of this file.
1
/*
2
* Name : test_double_plus
3
* Author : Chris Koeritz
4
* Purpose: Tests the double_plus class out.
5
**
6
* Copyright (c) 2001-$now By Author. This program is free software; you can *
7
* redistribute it and/or modify it under the terms of the GNU General Public *
8
* License as published by the Free Software Foundation; either version 2 of *
9
* the License or (at your option) any later version. This is online at: *
10
* http://www.fsf.org/copyleft/gpl.html *
11
* Please send any updates to: fred@gruntose.com *
12
*/
13
14
#include <
application/hoople_main.h
>
15
#include <
basis/astring.h
>
16
#include <
geometric/angle.h
>
17
#include <
loggers/program_wide_logger.h
>
18
#include <
mathematics/double_plus.h
>
19
#include <
structures/static_memory_gremlin.h
>
20
#include <
unit_test/unit_base.h
>
21
22
using namespace
application
;
23
using namespace
basis
;
24
using namespace
geometric
;
25
using namespace
loggers
;
26
using namespace
mathematics
;
27
using namespace
structures
;
28
using namespace
unit_test
;
29
30
typedef
double_plus
floot
;
31
32
class
test_double_plus :
public
virtual
unit_base
,
public
virtual
application_shell
33
{
34
public
:
35
test_double_plus() :
application_shell
() {}
36
DEFINE_CLASS_NAME
(
"test_double_plus"
);
37
virtual
int
execute();
38
};
39
40
int
test_double_plus::execute()
41
{
42
FUNCDEF
(
"execute"
);
43
floot
x1 = 43.8106392325;
44
floot
x2 = 43.8106;
45
ASSERT_EQUAL
(x1, x2,
"these doubles should be close enough"
);
46
47
floot
y1 = 16.78;
48
floot
y2 = 16.798273773;
49
ASSERT_INEQUAL
(y1, y2,
"these doubles shouldn't be close enough"
);
50
51
floot
z1(16.8, 0.1);
52
floot
z2(16.798273773, 0.1);
53
ASSERT_EQUAL
(
a_sprintf
(
"%.3f"
, z2.truncate()),
astring
(
"16.800"
),
54
"truncate should calculate proper string"
);
55
ASSERT_EQUAL
(z1, z2,
"these doubles should be close enough with short delta"
);
56
57
floot
q1(16.75, 0.01);
58
floot
q2(16.749273773, 0.01);
59
ASSERT_EQUAL
(
a_sprintf
(
"%.3f"
, q2.truncate()),
astring
(
"16.750"
),
60
"wider truncate should calculate proper string"
);
61
ASSERT_EQUAL
(q1, q2,
"next couple doubles should be close enough with small delta"
);
62
63
return
final_report();
64
}
65
67
68
HOOPLE_MAIN
(test_double_plus, )
69
angle.h
astring.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
basis::astring
Provides a dynamically resizable ASCII character string.
Definition:
astring.h:35
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
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_double_plus.cpp:30
unit_base.h
ASSERT_EQUAL
#define ASSERT_EQUAL(a, b, test_name)
Definition:
unit_base.h:38
ASSERT_INEQUAL
#define ASSERT_INEQUAL(a, b, test_name)
Definition:
unit_base.h:42
nucleus
library
tests_mathematics
test_double_plus.cpp
Generated by
1.9.1