-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathtest_MeadeSync.cpp
More file actions
61 lines (50 loc) · 1.25 KB
/
Copy pathtest_MeadeSync.cpp
File metadata and controls
61 lines (50 loc) · 1.25 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 SyncControl dispatcher (`handleMeadeSyncControl`).
//
// `:CM#` syncs the mount to the previously-set target and emits "NONE#".
// Any other suffix elicits "FAIL#" with no handler call.
#include <gtest/gtest.h>
#include "core/meade/MeadeParser.hpp"
namespace meade = oat::core::meade;
namespace
{
class FakeHandlers : public meade::IMeadeSyncControlHandlers
{
public:
int callCount = 0;
void onSyncToTarget() override
{
++callCount;
}
};
const char *dispatch(const char *suffix, FakeHandlers &h)
{
static meade::MeadeResponse last;
last.clear();
meade::handleMeadeSyncControl(last, suffix, h);
return last.c_str();
}
} // namespace
TEST(MeadeSync, to_target_emits_none)
{
FakeHandlers h;
EXPECT_STREQ("NONE#", dispatch("M", h));
EXPECT_EQ(1, h.callCount);
}
TEST(MeadeSync, unknown_suffix_emits_fail)
{
FakeHandlers h;
EXPECT_STREQ("FAIL#", dispatch("Q", h));
EXPECT_EQ(0, h.callCount);
}
TEST(MeadeSync, empty_suffix_emits_fail)
{
FakeHandlers h;
EXPECT_STREQ("FAIL#", dispatch("", h));
EXPECT_EQ(0, h.callCount);
}
TEST(MeadeSync, trailing_bytes_emit_fail)
{
FakeHandlers h;
EXPECT_STREQ("FAIL#", dispatch("Mx", h));
EXPECT_EQ(0, h.callCount);
}