MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_factory_methods

Function test_factory_methods

tests/geometry/test-angle.cpp:32–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30#include <geode/tests/common.hpp>
31
32void test_factory_methods()
33{
34 std::vector< std::pair< double, double > > degrees_radians{
35 { -720., -4. * M_PI }, { -360., -2. * M_PI },
36 { -270., -3. * M_PI / 2. }, { -180., -M_PI },
37 { -135., -3. * M_PI / 4. }, { -90., -M_PI / 2. }, { -45., -M_PI / 4. },
38 { 0., 0. }, { 22.5, M_PI / 8. }, { 45., M_PI / 4. }, { 90., M_PI / 2. },
39 { 135., 3. * M_PI / 4. }, { 180., M_PI }, { 270., 3. * M_PI / 2. },
40 { 360., 2. * M_PI }, { 540., 3. * M_PI }, { 720., 4. * M_PI },
41 { 1080., 6. * M_PI }
42 };
43 for( const auto& angle : degrees_radians )
44 {
45 auto angle_deg = geode::Angle::create_from_degrees( angle.first );
46 geode::OpenGeodeGeometryException::test(
47 std::abs( angle_deg.degrees() - angle.first )
48 < geode::GLOBAL_ANGULAR_EPSILON,
49 "Wrong Angle from degree value ", angle_deg.degrees(),
50 " should be ", angle.first, " !" );
51 geode::OpenGeodeGeometryException::test(
52 std::abs( angle_deg.radians() - angle.second )
53 < geode::GLOBAL_ANGULAR_EPSILON,
54 "Wrong Angle from degree value ", angle_deg.degrees(),
55 " should be ", angle.second, " !" );
56
57 auto angle_rad = geode::Angle::create_from_radians( angle.second );
58 geode::OpenGeodeGeometryException::test(
59 std::abs( angle_rad.degrees() - angle.first )
60 < geode::GLOBAL_ANGULAR_EPSILON,
61 "Wrong Angle from radian value ", angle_rad.degrees(),
62 " should be ", angle.first, " !" );
63 geode::OpenGeodeGeometryException::test(
64 std::abs( angle_rad.radians() - angle.second )
65 < geode::GLOBAL_ANGULAR_EPSILON,
66 "Wrong Angle from radian value ", angle_rad.degrees(),
67 " should be ", angle.second, " !" );
68 }
69}
70
71void test_comparison_operators()
72{

Callers 1

testFunction · 0.70

Calls 3

degreesMethod · 0.80
radiansMethod · 0.80
testFunction · 0.70

Tested by

no test coverage detected