feisty meow concerns codebase  2.140
test_math_ops.cpp
Go to the documentation of this file.
1 /*****************************************************************************\
2 * *
3 * Name : test_math_ops *
4 * Author : Chris Koeritz *
5 * *
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 
16 #include <basis/guards.h>
17 #include <basis/astring.h>
18 #include <mathematics/math_ops.h>
19 #include <loggers/console_logger.h>
21 #include <unit_test/unit_base.h>
22 
23 using namespace application;
24 using namespace basis;
25 //using namespace filesystem;
26 using namespace loggers;
27 using namespace mathematics;
28 using namespace structures;
29 using namespace textual;
30 using namespace timely;
31 using namespace unit_test;
32 
33 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
34 
35 class test_math_ops : virtual public unit_base, virtual public application_shell
36 {
37 public:
38  test_math_ops() {}
39  DEFINE_CLASS_NAME("test_math_ops");
40  virtual int execute();
41 };
42 
44 
45 int test_math_ops::execute()
46 {
47  FUNCDEF("execute");
48  // test one: make sure factorial is working.
49  basis::un_int fact3 = math_ops::factorial(3);
50  ASSERT_EQUAL(fact3, 6, "3! did not equal 6");
51  basis::un_int fact8 = math_ops::factorial(8);
52  ASSERT_EQUAL(fact8, 40320, "8! did not equal 40320");
53  basis::un_int fact10 = math_ops::factorial(10);
54  ASSERT_EQUAL(fact10, 3628800, "10! did not equal 3628800");
55 
56  return final_report();
57 }
58 
59 HOOPLE_MAIN(test_math_ops, )
60 
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.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition: hoople_main.h:61
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
unsigned int un_int
Abbreviated name for unsigned integers.
Definition: definitions.h:62
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
Definition: averager.h:21
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55
#include <time.h>
Definition: earth_time.cpp:37
Useful support functions for unit testing, especially within hoople.
Definition: unit_base.cpp:35
#define ASSERT_EQUAL(a, b, test_name)
Definition: unit_base.h:38