4 #include "gtest/gtest.h" 6 TEST(KvhDsp3000Parser, normalInput)
8 char input[] =
" 0.015733 1\r\n";
13 EXPECT_FLOAT_EQ(0.015733, parsed_data.
value);
17 TEST(KvhDsp3000Parser, normalInputButNoSpace)
19 char input[] =
"0.015733 1\r\n";
26 TEST(KvhDsp3000Parser, normalInputButNoSpaceAndEnd)
28 char input[] =
"0.015733 1";
35 TEST(KvhDsp3000Parser, onlyValue)
37 int constexpr DATA_LEN = 17;
38 static char const *
const DATA =
" 0.015733 ";
39 char input[DATA_LEN + 1];
41 memcpy(input, DATA, DATA_LEN + 1);
48 EXPECT_STREQ(DATA, input);
51 TEST(KvhDsp3000Parser, onlyValid)
53 char input[] =
" 1\r\n";
60 TEST(KvhDsp3000Parser, onlyValidThenNormal)
62 static char const *
const EXPECTED_INTERMEDIATE_DATA =
" 0.015733 1\r\n";
63 char input[] =
" 1\r\n 0.015733 1\r\n";
67 EXPECT_EQ(strlen(EXPECTED_INTERMEDIATE_DATA), parsed_data_valid.
new_buffer_length);
71 ASSERT_STREQ(input, EXPECTED_INTERMEDIATE_DATA);
75 EXPECT_FLOAT_EQ(0.015733, parsed_data_normal.
value);
79 int main(
int argc,
char **argv)
81 testing::InitGoogleTest(&argc, argv);
82 return RUN_ALL_TESTS();
ParseDsp3000Data parse_dsp3000(char *buffer, int buffer_size)
bool is_sensor_data_valid
Copyright Autonomous Solutions Inc. 2016.
int main(int argc, char **argv)
TEST(KvhDsp3000Parser, normalInput)
Copyright Autonomous Solutions Inc. 2016.