first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / tests_mathematics / test_math_ops.cpp
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
15 #include <application/hoople_main.h>
16 #include <basis/guards.h>
17 #include <basis/astring.h>
18 #include <mathematics/math_ops.h>
19 #include <loggers/console_logger.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 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
43 //////////////
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