建立 MAG160C 逆向工程交接仓库
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include "core/tcm_device.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
void test_rotate_positive_payload() {
|
||||
mag160c::core::TcmCommandBuilder builder;
|
||||
const std::vector<uint8_t> expected{
|
||||
0x7e, 0x00, 0x07, 0x85, 0x02, 0x77, 0x00, 0x01, 0x00, 0x05, 0x7f};
|
||||
|
||||
const auto encoded = builder.build_rotate_frame(5);
|
||||
|
||||
assert(encoded == expected);
|
||||
}
|
||||
|
||||
void test_rotate_negative_payload_and_frame_increment() {
|
||||
mag160c::core::TcmCommandBuilder builder;
|
||||
(void)builder.build_rotate_frame(5);
|
||||
|
||||
const std::vector<uint8_t> expected{
|
||||
0x7e, 0x00, 0x07, 0x85, 0x02, 0x77, 0x00, 0x02, 0x01, 0x03, 0x7f};
|
||||
|
||||
const auto encoded = builder.build_rotate_frame(-3);
|
||||
|
||||
assert(encoded == expected);
|
||||
}
|
||||
|
||||
void test_green_blink_payload() {
|
||||
mag160c::core::TcmCommandBuilder builder;
|
||||
const std::vector<uint8_t> expected{
|
||||
0x7e, 0x00, 0x09, 0x87, 0x02, 0x32, 0x00, 0x01, 0x01, 0x00, 0xff, 0x00, 0x35};
|
||||
|
||||
const auto encoded = builder.build_light_frame(MAG160C_TCM_LIGHT_GREEN, MAG160C_TCM_LIGHT_BLINK);
|
||||
|
||||
assert(encoded == expected);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
test_rotate_positive_payload();
|
||||
test_rotate_negative_payload_and_frame_increment();
|
||||
test_green_blink_payload();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user