-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathtest_MeadeSlewRate.cpp
More file actions
85 lines (70 loc) · 1.69 KB
/
test_MeadeSlewRate.cpp
File metadata and controls
85 lines (70 loc) · 1.69 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Wire-byte tests for the Meade SetSlewRate dispatcher (`handleMeadeSetSlewRate`).
//
// `:RS#`/`:RM#`/`:RC#`/`:RG#` map to mount slew rates 4/3/2/1 with empty wire
// responses. Unknown or malformed suffixes are ignored and emit empty.
#include <gtest/gtest.h>
#include "core/meade/MeadeParser.hpp"
namespace meade = oat::core::meade;
namespace
{
class FakeHandlers : public meade::IMeadeSlewRateHandlers
{
public:
int lastRate = -1;
int callCount = 0;
void onSetSlewRate(uint8_t rate) override
{
lastRate = static_cast<int>(rate);
++callCount;
}
};
const char *dispatch(const char *suffix, FakeHandlers &h)
{
static meade::MeadeResponse last;
last.clear();
meade::handleMeadeSetSlewRate(last, suffix, h);
return last.c_str();
}
} // namespace
TEST(MeadeSlewRate, s_sets_4)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("S", h));
EXPECT_EQ(4, h.lastRate);
}
TEST(MeadeSlewRate, m_sets_3)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("M", h));
EXPECT_EQ(3, h.lastRate);
}
TEST(MeadeSlewRate, c_sets_2)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("C", h));
EXPECT_EQ(2, h.lastRate);
}
TEST(MeadeSlewRate, g_sets_1)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("G", h));
EXPECT_EQ(1, h.lastRate);
}
TEST(MeadeSlewRate, unknown_suffix_no_call)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("Q", h));
EXPECT_EQ(0, h.callCount);
}
TEST(MeadeSlewRate, multi_char_suffix_no_call)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("SS", h));
EXPECT_EQ(0, h.callCount);
}
TEST(MeadeSlewRate, empty_suffix_no_call)
{
FakeHandlers h;
EXPECT_STREQ("", dispatch("", h));
EXPECT_EQ(0, h.callCount);
}