-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathtest_MeadeInit.cpp
More file actions
46 lines (37 loc) · 888 Bytes
/
test_MeadeInit.cpp
File metadata and controls
46 lines (37 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Wire-byte tests for the Meade Init dispatcher (`handleMeadeInit`).
//
// `:I#` hands UI over to serial control; the wire response is empty.
#include <gtest/gtest.h>
#include "core/meade/MeadeParser.hpp"
namespace meade = oat::core::meade;
namespace
{
class FakeHandlers : public meade::IMeadeInitHandlers
{
public:
int callCount = 0;
void onEnterSerialControl() override
{
++callCount;
}
};
const char *dispatch(const char *suffix, FakeHandlers &h)
{
static meade::MeadeResponse last;
last.clear();
meade::handleMeadeInit(last, suffix, h);
return last.c_str();
}
} // namespace
TEST(MeadeInit, empty_response)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("", h));
EXPECT_EQ(1, h.callCount);
}
TEST(MeadeInit, ignores_suffix)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("xyz", h));
EXPECT_EQ(1, h.callCount);
}