mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
unittests: Add unittests for geo_mag_declination.
This commit is contained in:
parent
ab9fa59dd2
commit
fc34eef53a
@ -110,3 +110,5 @@ add_executable(param_test param_test.cpp uorb_stub.cpp
|
||||
${PX4_SRC}/modules/systemlib/param/param.c)
|
||||
target_link_libraries(param_test ${PX4_PLATFORM})
|
||||
add_gtest(param_test)
|
||||
add_executable(geomag_test geomag_test.cpp)
|
||||
add_gtest(geomag_test)
|
||||
|
||||
16
unittests/geomag_test.cpp
Normal file
16
unittests/geomag_test.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include <geo_lookup/geo_mag_declination.c>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(GeoMagTest, IndexBoundsCheck)
|
||||
{
|
||||
unsigned index = get_lookup_table_index(90.0f, SAMPLING_MIN_LAT, SAMPLING_MAX_LAT);
|
||||
ASSERT_EQ((unsigned)11, index);
|
||||
index = get_lookup_table_index(-90.0f, SAMPLING_MIN_LAT, SAMPLING_MAX_LAT);
|
||||
ASSERT_EQ((unsigned)0, index);
|
||||
index = get_lookup_table_index(180.0f, SAMPLING_MIN_LON, SAMPLING_MAX_LON);
|
||||
ASSERT_EQ((unsigned)35, index);
|
||||
index = get_lookup_table_index(-180.0f, SAMPLING_MIN_LON, SAMPLING_MAX_LON);
|
||||
ASSERT_EQ((unsigned)0, index);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user