forked from Archive/PX4-Autopilot
unittests fix code style
This commit is contained in:
parent
fb040f9117
commit
b55fe24161
|
@ -1,6 +1,6 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(AutoDeclinationTest, AutoDeclination) {
|
||||
TEST(AutoDeclinationTest, AutoDeclination)
|
||||
{
|
||||
ASSERT_NEAR(get_mag_declination(47.0, 8.0), 0.6, 0.5) << "declination differs more than 1 degree";
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(ConversionTest, quad_w_main) {
|
||||
ASSERT_EQ(test_conv(0, NULL), 0) << "Conversion test failed";
|
||||
TEST(ConversionTest, quad_w_main)
|
||||
{
|
||||
ASSERT_EQ(test_conv(0, NULL), 0) << "Conversion test failed";
|
||||
}
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
#include <drivers/drv_hrt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
hrt_abstime hrt_absolute_time() {
|
||||
struct timeval te;
|
||||
gettimeofday(&te, NULL); // get current time
|
||||
hrt_abstime us = static_cast<uint64_t>(te.tv_sec) * 1e6 + te.tv_usec; // caculate us
|
||||
return us;
|
||||
hrt_abstime hrt_absolute_time()
|
||||
{
|
||||
struct timeval te;
|
||||
gettimeofday(&te, NULL); // get current time
|
||||
hrt_abstime us = static_cast<uint64_t>(te.tv_sec) * 1e6 + te.tv_usec; // caculate us
|
||||
return us;
|
||||
}
|
||||
|
||||
hrt_abstime hrt_elapsed_time(const volatile hrt_abstime *then) {
|
||||
hrt_abstime hrt_elapsed_time(const volatile hrt_abstime *then)
|
||||
{
|
||||
// not thread safe
|
||||
return hrt_absolute_time() - *then;
|
||||
return hrt_absolute_time() - *then;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
TEST(MixerTest, Mixer) {
|
||||
char* args[] = {"empty", "../ROMFS/px4fmu_common/mixers/IO_pass.mix", "../ROMFS/px4fmu_common/mixers/quad_w.main.mix"};
|
||||
TEST(MixerTest, Mixer)
|
||||
{
|
||||
char *args[] = {"empty", "../ROMFS/px4fmu_common/mixers/IO_pass.mix", "../ROMFS/px4fmu_common/mixers/quad_w.main.mix"};
|
||||
ASSERT_EQ(test_mixer(3, args), 0) << "IO_pass.mix failed";
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ struct param_info_s *param_info_limit;
|
|||
/*
|
||||
* Adds test parameters
|
||||
*/
|
||||
void _add_parameters() {
|
||||
void _add_parameters()
|
||||
{
|
||||
struct param_info_s test_1 = {
|
||||
"TEST_1",
|
||||
PARAM_TYPE_INT32
|
||||
|
@ -44,17 +45,19 @@ void _add_parameters() {
|
|||
param_array[3] = rc2_x;
|
||||
param_info_base = (struct param_info_s *) ¶m_array[0];
|
||||
param_info_limit = (struct param_info_s *) ¶m_array[4]; // needs to point at the end of the data,
|
||||
// therefore number of params + 1
|
||||
// therefore number of params + 1
|
||||
}
|
||||
|
||||
void _assert_parameter_int_value(param_t param, int32_t expected) {
|
||||
void _assert_parameter_int_value(param_t param, int32_t expected)
|
||||
{
|
||||
int32_t value;
|
||||
int result = param_get(param, &value);
|
||||
ASSERT_EQ(0, result) << printf("param_get (%i) did not return parameter\n", param);
|
||||
ASSERT_EQ(expected, value) << printf("value for param (%i) doesn't match default value\n", param);
|
||||
}
|
||||
|
||||
void _set_all_int_parameters_to(int32_t value) {
|
||||
void _set_all_int_parameters_to(int32_t value)
|
||||
{
|
||||
param_set((param_t)0, &value);
|
||||
param_set((param_t)1, &value);
|
||||
param_set((param_t)2, &value);
|
||||
|
@ -66,9 +69,10 @@ void _set_all_int_parameters_to(int32_t value) {
|
|||
_assert_parameter_int_value((param_t)3, value);
|
||||
}
|
||||
|
||||
TEST(ParamTest, SimpleFind) {
|
||||
TEST(ParamTest, SimpleFind)
|
||||
{
|
||||
_add_parameters();
|
||||
|
||||
|
||||
param_t param = param_find("TEST_2");
|
||||
ASSERT_NE(PARAM_INVALID, param) << "param_find did not find parameter";
|
||||
|
||||
|
@ -78,7 +82,8 @@ TEST(ParamTest, SimpleFind) {
|
|||
ASSERT_EQ(4, value) << "value of returned parameter does not match";
|
||||
}
|
||||
|
||||
TEST(ParamTest, ResetAll) {
|
||||
TEST(ParamTest, ResetAll)
|
||||
{
|
||||
_add_parameters();
|
||||
_set_all_int_parameters_to(50);
|
||||
|
||||
|
@ -90,11 +95,12 @@ TEST(ParamTest, ResetAll) {
|
|||
_assert_parameter_int_value((param_t)3, 16);
|
||||
}
|
||||
|
||||
TEST(ParamTest, ResetAllExcludesOne) {
|
||||
TEST(ParamTest, ResetAllExcludesOne)
|
||||
{
|
||||
_add_parameters();
|
||||
_set_all_int_parameters_to(50);
|
||||
|
||||
const char* excludes[] = {"RC_X"};
|
||||
const char *excludes[] = {"RC_X"};
|
||||
param_reset_excludes(excludes, 1);
|
||||
|
||||
_assert_parameter_int_value((param_t)0, 2);
|
||||
|
@ -103,11 +109,12 @@ TEST(ParamTest, ResetAllExcludesOne) {
|
|||
_assert_parameter_int_value((param_t)3, 16);
|
||||
}
|
||||
|
||||
TEST(ParamTest, ResetAllExcludesTwo) {
|
||||
TEST(ParamTest, ResetAllExcludesTwo)
|
||||
{
|
||||
_add_parameters();
|
||||
_set_all_int_parameters_to(50);
|
||||
|
||||
const char* excludes[] = {"RC_X", "TEST_1"};
|
||||
const char *excludes[] = {"RC_X", "TEST_1"};
|
||||
param_reset_excludes(excludes, 2);
|
||||
|
||||
_assert_parameter_int_value((param_t)0, 50);
|
||||
|
@ -116,11 +123,12 @@ TEST(ParamTest, ResetAllExcludesTwo) {
|
|||
_assert_parameter_int_value((param_t)3, 16);
|
||||
}
|
||||
|
||||
TEST(ParamTest, ResetAllExcludesBoundaryCheck) {
|
||||
TEST(ParamTest, ResetAllExcludesBoundaryCheck)
|
||||
{
|
||||
_add_parameters();
|
||||
_set_all_int_parameters_to(50);
|
||||
|
||||
const char* excludes[] = {"RC_X", "TEST_1"};
|
||||
const char *excludes[] = {"RC_X", "TEST_1"};
|
||||
param_reset_excludes(excludes, 1);
|
||||
|
||||
_assert_parameter_int_value((param_t)0, 2);
|
||||
|
@ -129,11 +137,12 @@ TEST(ParamTest, ResetAllExcludesBoundaryCheck) {
|
|||
_assert_parameter_int_value((param_t)3, 16);
|
||||
}
|
||||
|
||||
TEST(ParamTest, ResetAllExcludesWildcard) {
|
||||
TEST(ParamTest, ResetAllExcludesWildcard)
|
||||
{
|
||||
_add_parameters();
|
||||
_set_all_int_parameters_to(50);
|
||||
|
||||
const char* excludes[] = {"RC*"};
|
||||
const char *excludes[] = {"RC*"};
|
||||
param_reset_excludes(excludes, 1);
|
||||
|
||||
_assert_parameter_int_value((param_t)0, 2);
|
||||
|
|
|
@ -67,30 +67,26 @@
|
|||
* Global Type Declarations
|
||||
************************************************************************/
|
||||
|
||||
struct sq_entry_s
|
||||
{
|
||||
FAR struct sq_entry_s *flink;
|
||||
struct sq_entry_s {
|
||||
FAR struct sq_entry_s *flink;
|
||||
};
|
||||
typedef struct sq_entry_s sq_entry_t;
|
||||
|
||||
struct dq_entry_s
|
||||
{
|
||||
FAR struct dq_entry_s *flink;
|
||||
FAR struct dq_entry_s *blink;
|
||||
struct dq_entry_s {
|
||||
FAR struct dq_entry_s *flink;
|
||||
FAR struct dq_entry_s *blink;
|
||||
};
|
||||
typedef struct dq_entry_s dq_entry_t;
|
||||
|
||||
struct sq_queue_s
|
||||
{
|
||||
FAR sq_entry_t *head;
|
||||
FAR sq_entry_t *tail;
|
||||
struct sq_queue_s {
|
||||
FAR sq_entry_t *head;
|
||||
FAR sq_entry_t *tail;
|
||||
};
|
||||
typedef struct sq_queue_s sq_queue_t;
|
||||
|
||||
struct dq_queue_s
|
||||
{
|
||||
FAR dq_entry_t *head;
|
||||
FAR dq_entry_t *tail;
|
||||
struct dq_queue_s {
|
||||
FAR dq_entry_t *head;
|
||||
FAR dq_entry_t *tail;
|
||||
};
|
||||
typedef struct dq_queue_s dq_queue_t;
|
||||
|
||||
|
@ -110,11 +106,11 @@ EXTERN void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue);
|
|||
EXTERN void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
EXTERN void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue);
|
||||
EXTERN void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node,
|
||||
sq_queue_t *queue);
|
||||
sq_queue_t *queue);
|
||||
EXTERN void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node,
|
||||
dq_queue_t *queue);
|
||||
dq_queue_t *queue);
|
||||
EXTERN void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node,
|
||||
dq_queue_t *queue);
|
||||
dq_queue_t *queue);
|
||||
|
||||
EXTERN FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
EXTERN void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue);
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(SBUS2Test, SBUS2) {
|
||||
TEST(SBUS2Test, SBUS2)
|
||||
{
|
||||
const char *filepath = "testdata/sbus2_r7008SB.txt";
|
||||
|
||||
FILE *fp;
|
||||
fp = fopen(filepath,"rt");
|
||||
fp = fopen(filepath, "rt");
|
||||
|
||||
ASSERT_TRUE(fp);
|
||||
warnx("loading data from: %s", filepath);
|
||||
|
@ -51,8 +52,9 @@ TEST(SBUS2Test, SBUS2) {
|
|||
|
||||
//warnx("%f: 0x%02x, first: 0x%02x, last: 0x%02x, pcount: %u", (double)f, x, frame[0], frame[24], partial_frame_count);
|
||||
|
||||
if (partial_frame_count == sizeof(frame))
|
||||
if (partial_frame_count == sizeof(frame)) {
|
||||
partial_frame_count = 0;
|
||||
}
|
||||
|
||||
last_time = f;
|
||||
|
||||
|
@ -60,7 +62,7 @@ TEST(SBUS2Test, SBUS2) {
|
|||
hrt_abstime now = hrt_absolute_time();
|
||||
|
||||
//if (partial_frame_count % 25 == 0)
|
||||
//sbus_parse(now, frame, &partial_frame_count, rc_values, &num_values, &sbus_failsafe, &sbus_frame_drop, max_channels);
|
||||
//sbus_parse(now, frame, &partial_frame_count, rc_values, &num_values, &sbus_failsafe, &sbus_frame_drop, max_channels);
|
||||
}
|
||||
|
||||
ASSERT_EQ(ret, EOF);
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(SF0XTest, SF0X) {
|
||||
TEST(SF0XTest, SF0X)
|
||||
{
|
||||
const char _LINE_MAX = 20;
|
||||
char _linebuf[_LINE_MAX];
|
||||
_linebuf[0] = '\0';
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(ST24Test, ST24) {
|
||||
const char* filepath = "testdata/st24_data.txt";
|
||||
TEST(ST24Test, ST24)
|
||||
{
|
||||
const char *filepath = "testdata/st24_data.txt";
|
||||
|
||||
warnx("loading data from: %s", filepath);
|
||||
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
* TODO: use googlemock
|
||||
******************************************/
|
||||
|
||||
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data) {
|
||||
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data)
|
||||
{
|
||||
return (orb_advert_t)0;
|
||||
}
|
||||
|
||||
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data) {
|
||||
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue