41 #include <px4_platform_common/px4_config.h> 57 virtual bool run_tests();
60 bool singlePrecisionTests();
61 bool doublePrecisionTests();
66 float sinf_zero = sinf(0.0
f);
67 float sinf_one = sinf(1.0
f);
68 float sqrt_two = sqrtf(2.0
f);
71 ut_assert(
"sinf(1.0f) == 0.84147f", fabsf((sinf_one - 0.841470956802368164062500000000
f)) <
FLT_EPSILON);
73 float asinf_one = asinf(1.0
f);
74 ut_assert(
"asinf(1.0f) == 1.57079f", fabsf((asinf_one - 1.570796251296997070312500000000
f)) <
FLT_EPSILON * 1.5
f);
76 float cosf_one = cosf(1.0f);
77 ut_assert(
"cosf(1.0f) == 0.54030f", fabsf((cosf_one - 0.540302336215972900390625000000f)) <
FLT_EPSILON);
79 float acosf_one = acosf(1.0f);
80 ut_assert(
"acosf(1.0f) == 0.0f", fabsf((acosf_one - 0.000000000000000000000000000000f)) <
FLT_EPSILON);
82 float sinf_zero_one = sinf(0.1f);
87 float atan2f_ones = atan2f(1.0f, 1.0f);
88 ut_assert(
"atan2f(1.0f, 1.0f) == 0.78539f",
89 fabsf(atan2f_ones - 0.785398163397448278999490867136f) < 2.0f *
FLT_EPSILON);
92 sprintf(sbuf,
"%8.4f", (
double)0.553415f);
103 sprintf(sbuf,
"%8.4f", (
double) - 0.553415f);
125 double d1d2 = d1 * d2;
127 ut_assert(
"1.0111 * 2.0 == 2.0222", fabs(d1d2 - 2.022200000000000219557705349871) < DBL_EPSILON);
135 double sin_zero =
sin(0.0);
136 double sin_one =
sin(1.0);
137 double atan2_ones =
atan2(1.0, 1.0);
139 ut_assert(
"sin(0.0) == 0.0", fabs(sin_zero - 0.0) < DBL_EPSILON);
140 ut_assert(
"sin(1.0) == 0.84147098480", fabs(sin_one - 0.841470984807896504875657228695) < DBL_EPSILON);
141 ut_assert(
"atan2(1.0, 1.0) == 0.785398", fabs(atan2_ones - 0.785398163397448278999490867136) < 2.0 * DBL_EPSILON);
142 ut_assert(
"testing pow() with magic value",
143 (44330.0 * (1.0 - pow((96286LL / 101325.0), 0.190295))) - 428.2293 < DBL_EPSILON);
147 sprintf(sbuf,
"%8.4f", 0.553415);
159 sprintf(sbuf,
"%8.4f", -0.553415);
178 return (_tests_failed == 0);
bool singlePrecisionTests()
#define ut_declare_test_c(test_function, test_class)
Base class to be used for unit tests.
#define ut_assert(message, test)
Used to assert a value within a unit test.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
virtual bool run_tests()
Override to run your unit tests.
int test_float(int argc, char *argv[])
#define ut_compare(message, v1, v2)
Used to compare two integer values within a unit test.
#define ut_run_test(test)
Runs a single unit test.
bool doublePrecisionTests()
Dual< Scalar, N > sin(const Dual< Scalar, N > &a)
Dual< Scalar, N > atan2(const Dual< Scalar, N > &a, const Dual< Scalar, N > &b)