diff options
-rw-r--r-- | unittests/sbus2_test.cpp | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/unittests/sbus2_test.cpp b/unittests/sbus2_test.cpp index ba075f8b3..ee4f3d1d6 100644 --- a/unittests/sbus2_test.cpp +++ b/unittests/sbus2_test.cpp @@ -1,33 +1,23 @@ - #include <stdio.h> -#include <unistd.h> #include <string.h> -#include <systemlib/mixer/mixer.h> -#include <systemlib/err.h> +#include <unistd.h> + +#include "../../src/systemcmds/tests/tests.h" #include <drivers/drv_hrt.h> #include <px4iofirmware/px4io.h> -#include "../../src/systemcmds/tests/tests.h" - -int main(int argc, char *argv[]) { - warnx("SBUS2 test started"); - - char *filepath = 0; +#include <systemlib/err.h> +#include <systemlib/mixer/mixer.h> - if (argc < 2) { - warnx("Using default input file"); - filepath = "testdata/sbus2_r7008SB.txt"; - } else { - filepath = argv[1]; - } +#include "gtest/gtest.h" - warnx("loading data from: %s", filepath); +TEST(SBUS2Test, SBUS2) { + char *filepath = "testdata/sbus2_r7008SB.txt"; FILE *fp; - fp = fopen(filepath,"rt"); - if (!fp) - errx(1, "failed opening file"); + ASSERT_TRUE(fp); + warnx("loading data from: %s", filepath); float f; unsigned x; @@ -73,12 +63,5 @@ int main(int argc, char *argv[]) { //sbus_parse(now, frame, &partial_frame_count, rc_values, &num_values, &sbus_failsafe, &sbus_frame_drop, max_channels); } - if (ret == EOF) { - warnx("Test finished, reached end of file"); - ret = 0; - } else { - warnx("Test aborted, errno: %d", ret); - } - - return ret; + ASSERT_EQ(ret, EOF); } |