-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathtest_MeadeDistance.cpp
More file actions
61 lines (50 loc) · 1.28 KB
/
test_MeadeDistance.cpp
File metadata and controls
61 lines (50 loc) · 1.28 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
// Wire-byte tests for the Meade Distance-bars dispatcher (`handleMeadeDistance`).
//
// The `:D#` command reports motion status as a single byte ('|' while
// slewing, ' ' when idle) followed by the standard terminator. Any suffix
// is treated identically (legacy lenient behaviour).
#include <gtest/gtest.h>
#include "core/meade/MeadeParser.hpp"
namespace meade = oat::core::meade;
namespace
{
class FakeHandlers : public meade::IMeadeDistanceHandlers
{
public:
bool slewing = false;
int callCount = 0;
bool onIsSlewingRaOrDec() override
{
++callCount;
return slewing;
}
};
const char *dispatch(const char *suffix, FakeHandlers &h)
{
static meade::MeadeResponse last;
last.clear();
meade::handleMeadeDistance(last, suffix, h);
return last.c_str();
}
} // namespace
TEST(MeadeDistance, idle_emits_space)
{
FakeHandlers h;
h.slewing = false;
EXPECT_STREQ(" #", dispatch("", h));
EXPECT_EQ(1, h.callCount);
}
TEST(MeadeDistance, slewing_emits_pipe)
{
FakeHandlers h;
h.slewing = true;
EXPECT_STREQ("|#", dispatch("", h));
EXPECT_EQ(1, h.callCount);
}
TEST(MeadeDistance, ignores_suffix_bytes)
{
FakeHandlers h;
h.slewing = true;
EXPECT_STREQ("|#", dispatch("xyz", h));
EXPECT_EQ(1, h.callCount);
}