Skip to content

Commit

Permalink
Add extra unit test.
Browse files Browse the repository at this point in the history
- Confirm User's poor data can be captured with an increased tolerance value of 10% extra.

Ref #1289
  • Loading branch information
crankyoldgit committed Oct 8, 2020
1 parent 0b03ad9 commit 3ee88f1
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/ir_Mirage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,46 @@ TEST(TestDecodeMirage, SyntheticExample) {
"",
IRAcUtils::resultAcToString(&irsend.capture));
}

// Data from:
// https://github.com/crankyoldgit/IRremoteESP8266/issues/1289#issuecomment-705624234
TEST(TestDecodeMirage, RealExampleWithDodgyHardwareCapture) {
IRsendTest irsend(kGpioUnused);
IRrecv irrecv(kGpioUnused);
const uint16_t rawData[243] = {
8360, 4248, 582, 518, 556, 1582, 586, 1572, 528, 572, 556, 1590, 526, 572,
554, 1586, 528, 578, 558, 1582, 556, 542, 558, 1598, 528, 572, 556, 1590,
528, 1610, 556, 1600, 554, 546, 556, 544, 558, 542, 558, 542, 676, 400,
606, 492, 582, 542, 556, 544, 556, 542, 558, 544, 556, 542, 556, 544, 558,
542, 556, 544, 530, 570, 586, 516, 584, 514, 558, 542, 558, 542, 558, 542,
554, 546, 558, 542, 558, 1582,
734, 342, // Really poor data here.
580, 552, 528, 1610, 556, 544, 554, 546, 554, 544, 556, 544, 556, 544,
558, 542, 558, 552, 558, 542, 558, 542, 558, 542, 556, 544, 558, 542, 558,
542, 554, 544, 584, 516, 558, 542, 528, 572, 588, 512, 556, 544, 532, 568,
560, 542, 558, 542, 560, 540, 560, 538, 530, 570, 558, 542, 558, 542, 560,
540, 558, 542, 558, 542, 530, 568, 558, 542, 558, 542, 532, 570, 530, 570,
558, 542, 558, 542, 558, 542, 530, 570, 530, 568, 560, 540, 560, 540, 532,
568, 558, 542, 558, 542, 532, 568, 560, 542, 532, 568, 532, 568, 530, 570,
532, 570, 530, 570, 558, 540, 560, 540, 558, 534, 558, 542, 556, 1600,
558, 1592, 558, 542, 560, 1590, 530, 570, 530, 570, 556, 544, 560, 540,
556, 544, 558, 1582, 556, 544, 558, 1600, 556, 542, 560, 542, 532, 568,
558, 542, 610, 1538, 504, 1646, 582, 518, 528, 572, 528, 1612, 556, 544,
528, 580, 554}; // UNKNOWN 28DACDC4
const uint8_t expected[kMirageStateLength] = {
0x6A, 0xAE, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x68, 0x28, 0x64};
irrecv.setTolerance(kTolerance + 10); // Bump tolerance to match poor data.
irsend.begin();
irsend.reset();
irsend.sendRaw(rawData, 243, 38);
irsend.makeDecodeResult();

ASSERT_TRUE(irrecv.decode(&irsend.capture));
ASSERT_EQ(decode_type_t::MIRAGE, irsend.capture.decode_type);
ASSERT_EQ(kMirageBits, irsend.capture.bits);
EXPECT_STATE_EQ(expected, irsend.capture.state, irsend.capture.bits);
EXPECT_EQ(
"",
IRAcUtils::resultAcToString(&irsend.capture));
}

0 comments on commit 3ee88f1

Please sign in to comment.