move st24_test to gtest

This commit is contained in:
Daniel Agar
2015-01-07 23:15:12 -05:00
parent 6ed2f77ca5
commit a4db73dad8
2 changed files with 5 additions and 28 deletions
-2
View File
@@ -61,12 +61,10 @@ add_executable(conversion_test conversion_test.cpp ${PX_SRC}/systemcmds/tests/te
add_gtest(conversion_test) add_gtest(conversion_test)
# sbus2_test # sbus2_test
# TODO: move to gtest
add_executable(sbus2_test sbus2_test.cpp hrt.cpp) add_executable(sbus2_test sbus2_test.cpp hrt.cpp)
add_gtest(sbus2_test) add_gtest(sbus2_test)
# st24_test # st24_test
# TODO: move to gtest
add_executable(st24_test st24_test.cpp hrt.cpp ${PX_SRC}/lib/rc/st24.c) add_executable(st24_test st24_test.cpp hrt.cpp ${PX_SRC}/lib/rc/st24.c)
add_gtest(st24_test) add_gtest(st24_test)
+5 -26
View File
@@ -1,4 +1,3 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
@@ -7,30 +6,17 @@
#include <rc/st24.h> #include <rc/st24.h>
#include "../../src/systemcmds/tests/tests.h" #include "../../src/systemcmds/tests/tests.h"
int main(int argc, char *argv[]) #include "gtest/gtest.h"
{
warnx("ST24 test started");
char* defaultfile = "testdata/st24_data.txt"; TEST(ST24Test, ST24) {
const char* filepath = "testdata/st24_data.txt";
char* filepath = 0;
if (argc < 2) {
warnx("Too few arguments. Using default file: %s", defaultfile);
filepath = defaultfile;
} else {
filepath = argv[1];
}
warnx("loading data from: %s", filepath); warnx("loading data from: %s", filepath);
FILE *fp; FILE *fp;
fp = fopen(filepath, "rt"); fp = fopen(filepath, "rt");
//ASSERT_TRUE(fp);
if (!fp) {
errx(1, "failed opening file");
}
float f; float f;
unsigned x; unsigned x;
@@ -73,12 +59,5 @@ int main(int argc, char *argv[])
} }
} }
if (ret == EOF) { ASSERT_EQ(EOF, ret);
warnx("Test finished, reached end of file");
ret = 0;
} else {
warnx("Test aborted, errno: %d", ret);
}
return ret;
} }