aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds/tests
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-07-12 18:42:00 +0200
committerLorenz Meier <lm@inf.ethz.ch>2014-07-12 18:42:00 +0200
commitb288b010f12213a4388b627bce7fd6cb4cdedea5 (patch)
treef8ba166ac3b5c9f1a11fafd2fde3ae4cd3461a74 /src/systemcmds/tests
parent7b768d11c3c8d57807495bf2abb324bb5f14aa14 (diff)
downloadpx4-firmware-b288b010f12213a4388b627bce7fd6cb4cdedea5.tar.gz
px4-firmware-b288b010f12213a4388b627bce7fd6cb4cdedea5.tar.bz2
px4-firmware-b288b010f12213a4388b627bce7fd6cb4cdedea5.zip
tests, drive by: Fix double comparison, use reasonable margin based on context of test
Diffstat (limited to 'src/systemcmds/tests')
-rw-r--r--src/systemcmds/tests/test_bson.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/systemcmds/tests/test_bson.c b/src/systemcmds/tests/test_bson.c
index 6130fe763..12d598df4 100644
--- a/src/systemcmds/tests/test_bson.c
+++ b/src/systemcmds/tests/test_bson.c
@@ -40,6 +40,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <math.h>
#include <systemlib/err.h>
#include <systemlib/bson/tinybson.h>
@@ -123,7 +124,7 @@ decode_callback(bson_decoder_t decoder, void *private, bson_node_t node)
warnx("FAIL: decoder: double1 type %d, expected %d", node->type, BSON_DOUBLE);
return 1;
}
- if (node->d != sample_double) {
+ if (fabs(node->d - sample_double) > 1e-12) {
warnx("FAIL: decoder: double1 value %f, expected %f", node->d, sample_double);
return 1;
}