From d31b0cd5dbdbe13b783176d3e68290a25d14fb62 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Mon, 5 Jan 2015 22:12:25 -0500 Subject: move sbus2 to gtest --- unittests/sbus2_test.cpp | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'unittests') 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 -#include #include -#include -#include +#include + +#include "../../src/systemcmds/tests/tests.h" #include #include -#include "../../src/systemcmds/tests/tests.h" - -int main(int argc, char *argv[]) { - warnx("SBUS2 test started"); - - char *filepath = 0; +#include +#include - 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); } -- cgit v1.2.3