Pico GPS Teseo I2C
Loading...
Searching...
No Matches
test_gps_teseo_lib.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2#include <string>
3import teseo;
4
5const size_t NMEA_MAX_REPLIES = 7;
6
7class teseoTest : public testing::Test {
8protected:
9 teseoTest() : count(0), is_reset_called(false) {}
10 void SetUp() override {
11 o.writer().set([](const std::string& s) -> void { write(s); });
12 o.reader().set([](std::string& s) -> void { read(s); });
13 o.resetter().set([this]() -> void { reset(); });
14 }
15
16 static void write(const std::string& s) {
17 }
18 static void read(std::string& s) {
19 }
20 void reset() {
21 is_reset_called = true;;
22 }
23
25 return o.parse_multiline_reply(replies, reply, count, command);
26 }
27
29 std::string reply;
30 std::array<std::string, NMEA_MAX_REPLIES> replies;
31 unsigned int count;
33};
34
35TEST_F(teseoTest, parseMultilineReply) {
36 teseo::nmea_rr command("testcommand", "TST");
37 reply = "XXXTST\r\nXXXTST\r\ntestcommand\r\n";
38 EXPECT_TRUE(test_parse_multiline_reply(command));
39 EXPECT_EQ(count, 2);
40 EXPECT_STREQ(replies[0].c_str(), "XXXTST\r\n");
41 EXPECT_STREQ(replies[1].c_str(), "XXXTST\r\n");
42}
43
44TEST_F(teseoTest, parseSinglelineReply) {
45 teseo::nmea_rr command("testcommand", "TST");
46 reply = "XXXTST\r\ntestcommand\r\n";
47 EXPECT_TRUE(test_parse_multiline_reply(command));
48 EXPECT_EQ(count, 1);
49 EXPECT_STREQ(replies[0].c_str(), "XXXTST\r\n");
50}
51
52TEST_F(teseoTest, callbacksSet) {
53 EXPECT_TRUE(o.writer().is_set());
54 EXPECT_TRUE(o.reader().is_set());
55 EXPECT_TRUE(o.resetter().is_set());
56}
57
58TEST_F(teseoTest, callbacksExecute) {
59 EXPECT_FALSE(is_reset_called);
60 o.resetter()();
61 EXPECT_TRUE(is_reset_called);
62}
Driver class for ST Teseo IC.
static void write(const std::string &s)
bool test_parse_multiline_reply(const teseo::nmea_rr &command)
static void read(std::string &s)
std::string reply
teseo::teseo o
unsigned int count
std::array< std::string, NMEA_MAX_REPLIES > replies
void SetUp() override
const std::pair< const std::string, const std::string > nmea_rr
std::array< std::string, NMEA_MAX_REPLIES > replies
const size_t NMEA_MAX_REPLIES
TEST_F(teseoTest, parseMultilineReply)