Make wrap() work with integer types (#145)

* Make wrap() work with integers
This commit is contained in:
Morten Fyhn Amundsen
2020-08-24 10:49:12 +02:00
committed by GitHub
parent 25c0455348
commit cd8ad1584c
2 changed files with 57 additions and 11 deletions
+7
View File
@@ -21,6 +21,13 @@ int main()
TEST(fabs(wrap(360. - FLT_EPSILON, 0., 360.) - (360. - FLT_EPSILON)) < FLT_EPSILON);
TEST(fabs(wrap(360. + FLT_EPSILON, 0., 360.) - FLT_EPSILON) < FLT_EPSILON);
// integer wraps
TEST(wrap(-10, 0, 10) == 0);
TEST(wrap(-4, 0, 10) == 6);
TEST(wrap(0, 0, 10) == 0)
TEST(wrap(4, 0, 10) == 4);
TEST(wrap(10, 0, 10) == 0);
// wrap pi
TEST(fabs(wrap_pi(0.)) < FLT_EPSILON);
TEST(fabs(wrap_pi(4.) - (4. - M_TWOPI)) < FLT_EPSILON);