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>
21#include <unit_test/unit_base.h>
22
23using namespace application;
24using namespace basis;
25//using namespace filesystem;
26using namespace loggers;
27using namespace mathematics;
28using namespace structures;
29using namespace textual;
30using namespace timely;
31using namespace unit_test;
32
33#define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
34
35class test_math_ops : virtual public unit_base, virtual public application_shell
36{
37public:
38 test_math_ops() {}
39 DEFINE_CLASS_NAME("test_math_ops");
40 virtual int execute();
41};
42
44
45int test_math_ops::execute()
46{
47 FUNCDEF("execute");
48 // test one: make sure factorial is working.
50 ASSERT_EQUAL(fact3, 6, "3! did not equal 6");
52 ASSERT_EQUAL(fact8, 40320, "8! did not equal 40320");
54 ASSERT_EQUAL(fact10, 3628800, "10! did not equal 3628800");
55
56 return final_report();
57}
58
59HOOPLE_MAIN(test_math_ops, )
60
The application_shell is a base object for console programs.
virtual int execute()=0
< retrieves the command line from the /proc hierarchy on linux.
static basis::un_int factorial(int n)
returns n! (factorial), which is n * (n - 1) * (n - 2) ...
Definition math_ops.h:61
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition enhance_cpp.h:42
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition enhance_cpp.h:54
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>
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