Commit Graph

8 Commits

Author SHA1 Message Date
Lucas De Marchi 69a9cd3625 AP_Math: add tests to is_equal()
Contemplate the use of double values.
2017-01-27 12:15:19 -08:00
Pierre Kancir eae093cd2a AP_Math: add test for is_equal for int 2016-12-20 14:09:04 +00:00
Lucas De Marchi 348b07609c AP_Math: remove macros from unit tests
Avoid warnings like:

[2130/2168] Compiling libraries/AP_Math/tests/test_math.cpp
../../libraries/AP_Math/tests/test_math.cpp: In member function ‘virtual void MathTest_IsZero_Test::TestBody()’:
../../libraries/AP_Math/tests/test_math.cpp:73:196: warning: converting ‘false’ to pointer type for argument 1 of ‘char
testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null]
../../libraries/AP_Math/tests/test_math.cpp:74:199: warning: converting ‘false’ to pointer type for argument 1 of ‘char
testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null]

Use EXPECT_TRUE() and EXPECT_FALSE() from gtest instead.
2016-05-10 11:41:26 -03:00
dgrat 41661f815f AP_Math: Replace the pythagorous* functions with a variadic template
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
2016-05-10 11:41:26 -03:00
Lucas De Marchi 880f130670 AP_Math: fix loss of precision on float addition
When using wrap_180_cd() we are adding a small float (180 * 100) to a
possibly big number. This may lose float precision as illustrated by the
unit test failing:

    OUT: ../../libraries/AP_Math/tests/test_math.cpp:195: Failure
    OUT: Value of: wrap_180_cd(-3600000000.f)
    OUT:   Actual: -80
    OUT: Expected: 0.f
    OUT: Which is: 0
2016-05-10 11:41:26 -03:00
dgrat 76362caee0 AP_Math: Replace wrap_* functions with template versions 2016-05-10 11:41:26 -03:00
dgrat 49cfd6fd9b AP_Math: Add gtest support for some functions
These functions (or variants thereof) now have unit tests:

  - is_zero()
  - is_equal()
  - sq()
  - pythagorous()
  - constrain()
  - wrap_180()
  - wrap_360()

Some tests in wrap_180_cd are failing: -180 should be wrapped to 180,
not -180.
2016-05-10 11:41:26 -03:00
Lucas De Marchi ceea7540fd AP_Math: rename test file
This will be reused for more math tests.
2016-05-10 11:41:26 -03:00