3 * Author : Chris Koeritz *
5 * Tests the angle class. *
7 * Copyright (c) 2001-$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 *
15 #include <application/hoople_main.h>
16 #include <basis/astring.h>
17 #include <geometric/angle.h>
18 #include <loggers/program_wide_logger.h>
19 #include <mathematics/double_plus.h>
20 #include <structures/static_memory_gremlin.h>
21 #include <unit_test/unit_base.h>
23 using namespace application;
24 using namespace basis;
25 using namespace geometric;
26 using namespace loggers;
27 using namespace mathematics;
28 using namespace structures;
29 using namespace unit_test;
31 typedef double_plus floot;
33 class test_angle : public virtual unit_base, public virtual application_shell
36 test_angle() : application_shell() {}
37 DEFINE_CLASS_NAME("test_angle");
38 virtual int execute();
41 int test_angle::execute()
45 // first test group: double angle inverse trigonometrics.
46 angle<double> a(30.3, DEGREES);
47 ASSERT_EQUAL(floot(a.get(RADIANS)), floot(.528835), "radian conversion should be right");
50 angle<double> at = angle<double>::arctangent(28.3, 29.5, retval);
51 ASSERT_EQUAL(floot(at.get(DEGREES)), floot(43.8106), "atan should be what we expect");
52 angle<double> as = angle<double>::arcsine(17.6, 82.3, retval);
53 ASSERT_EQUAL(floot(as.get(DEGREES)), floot(12.3482), "asin should be what we expect");
54 angle<double> ac = angle<double>::arccosine(17.2, 42.0, retval);
55 ASSERT_EQUAL(floot(ac.get(DEGREES)), floot(65.8251), "acos should be what we expect");
58 // second test: packing an angle.
59 angle<double> q(128, DEGREES);
61 int siz = q.packed_size();
63 ASSERT_EQUAL(siz, pacd.length(), "packed size should report proper length");
66 ASSERT_EQUAL(floot(q.get(RADIANS)), floot(x.get(RADIANS)),
67 "unpacking should return original value");
68 ASSERT_FALSE(pacd.length(), "unpacking should consume entire array");
71 return final_report();
76 HOOPLE_MAIN(test_angle, )