-
Notifications
You must be signed in to change notification settings - Fork 838
/
Copy pathir_Inax_test.cpp
119 lines (104 loc) · 3.84 KB
/
ir_Inax_test.cpp
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2019 crankyoldgit (David Conran)
#include "IRsend.h"
#include "IRsend_test.h"
#include "IRutils.h"
#include "gtest/gtest.h"
// General housekeeping
TEST(TestInax, Housekeeping) {
ASSERT_EQ("INAX", typeToString(INAX));
ASSERT_FALSE(hasACState(INAX));
}
// Tests for sendInax().
// Test sending typical data only.
TEST(TestSendInax, SendDataOnly) {
IRsendTest irsend(0);
irsend.begin();
irsend.reset();
irsend.sendInax(0x5C32CD); // Small flush.
EXPECT_EQ(
"f38000d50"
"m9000s4500"
"m560s560m560s1675m560s560m560s1675m560s1675m560s1675m560s560m560s560"
"m560s560m560s560m560s1675m560s1675m560s560m560s560m560s1675m560s560"
"m560s1675m560s1675m560s560m560s560m560s1675m560s1675m560s560m560s1675"
"m560s40000"
"m9000s4500"
"m560s560m560s1675m560s560m560s1675m560s1675m560s1675m560s560m560s560"
"m560s560m560s560m560s1675m560s1675m560s560m560s560m560s1675m560s560"
"m560s1675m560s1675m560s560m560s560m560s1675m560s1675m560s560m560s1675"
"m560s40000",
irsend.outputStr());
irsend.reset();
}
// Test sending with different repeats.
TEST(TestSendInax, SendWithRepeats) {
IRsendTest irsend(0);
irsend.begin();
irsend.reset();
irsend.sendInax(0x5C32CD, kInaxBits, 0); // 0 repeats.
EXPECT_EQ(
"f38000d50"
"m9000s4500"
"m560s560m560s1675m560s560m560s1675m560s1675m560s1675m560s560m560s560"
"m560s560m560s560m560s1675m560s1675m560s560m560s560m560s1675m560s560"
"m560s1675m560s1675m560s560m560s560m560s1675m560s1675m560s560m560s1675"
"m560s40000",
irsend.outputStr());
irsend.sendInax(0x5C32CD, kInaxBits, 2); // 2 repeats.
EXPECT_EQ(
"f38000d50"
"m9000s4500"
"m560s560m560s1675m560s560m560s1675m560s1675m560s1675m560s560m560s560"
"m560s560m560s560m560s1675m560s1675m560s560m560s560m560s1675m560s560"
"m560s1675m560s1675m560s560m560s560m560s1675m560s1675m560s560m560s1675"
"m560s40000"
"m9000s4500"
"m560s560m560s1675m560s560m560s1675m560s1675m560s1675m560s560m560s560"
"m560s560m560s560m560s1675m560s1675m560s560m560s560m560s1675m560s560"
"m560s1675m560s1675m560s560m560s560m560s1675m560s1675m560s560m560s1675"
"m560s40000"
"m9000s4500"
"m560s560m560s1675m560s560m560s1675m560s1675m560s1675m560s560m560s560"
"m560s560m560s560m560s1675m560s1675m560s560m560s560m560s1675m560s560"
"m560s1675m560s1675m560s560m560s560m560s1675m560s1675m560s560m560s1675"
"m560s40000",
irsend.outputStr());
}
// Tests for decodeInax().
// Decode normal Inax messages.
TEST(TestDecodeInax, SyntheticDecode) {
IRsendTest irsend(0);
IRrecv irrecv(0);
irsend.begin();
// Normal Inax 24-bit message.
irsend.reset();
irsend.sendInax(0x5C32CD);
irsend.makeDecodeResult();
ASSERT_TRUE(irrecv.decode(&irsend.capture));
EXPECT_EQ(INAX, irsend.capture.decode_type);
EXPECT_EQ(kInaxBits, irsend.capture.bits);
EXPECT_EQ(0x5C32CD, irsend.capture.value);
EXPECT_EQ(0, irsend.capture.address);
EXPECT_EQ(0, irsend.capture.command);
}
// Decode real example via Issue #704
TEST(TestDecodeInax, DecodeExamples) {
IRsendTest irsend(0);
IRrecv irrecv(0);
irsend.begin();
irsend.reset();
// Inax Small Flush from Issue #309
uint16_t smallFlushRawData[51] = {
8996, 4474, 568, 556, 560, 1676, 568, 556, 562, 1676, 562, 1678, 566,
1674, 566, 558, 560, 560, 566, 556, 566, 556, 560, 1678, 562, 1676, 566,
556, 562, 560, 564, 1672, 566, 556, 562, 1676, 562, 1678, 562, 560, 564,
558, 564, 1674, 560, 1678, 564, 560, 566, 1670, 562};
irsend.sendRaw(smallFlushRawData, 51, 38);
irsend.makeDecodeResult();
ASSERT_TRUE(irrecv.decode(&irsend.capture));
EXPECT_EQ(INAX, irsend.capture.decode_type);
EXPECT_EQ(kInaxBits, irsend.capture.bits);
EXPECT_EQ(0x5C32CD, irsend.capture.value);
EXPECT_EQ(0, irsend.capture.address);
EXPECT_EQ(0, irsend.capture.command);
}