From 66e09b0ccb30c9586490a70596755d63e2cffe2b Mon Sep 17 00:00:00 2001 From: David Conran Date: Sun, 24 Feb 2019 17:15:04 +1000 Subject: [PATCH] Unit tests to help debug Issue #620 (#623) This doesn't change the operation of the library in any way. Just an additional Unit test to verify the library acts like we expect. This example/test helped show that problem was in someone else's code, not ours. --- test/ir_LG_test.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/ir_LG_test.cpp b/test/ir_LG_test.cpp index 8ab24a731..30ca07edc 100644 --- a/test/ir_LG_test.cpp +++ b/test/ir_LG_test.cpp @@ -420,3 +420,54 @@ TEST(TestDecodeLG2, RealLG2Example) { EXPECT_EQ(kLgBits, irsend.capture.bits); EXPECT_EQ(0x880094D, irsend.capture.value); } + +// Tests for issue reported in +// https://github.com/markszabo/IRremoteESP8266/issues/620 +TEST(TestDecodeLG, Issue620) { + IRsendTest irsend(0); + IRrecv irrecv(0); + irsend.begin(); + + // Raw data as reported in initial comment of Issue #620 + uint16_t rawData[59] = { + 8886, 4152, + 560, 1538, 532, 502, 532, 504, 530, 484, 558, 1536, + 508, 516, 558, 502, 532, 484, 558, 502, 532, 500, + 534, 508, 532, 502, 532, 1518, 558, 510, 532, 484, + 556, 486, 556, 510, 532, 1518, 558, 1560, 532, 1528, + 556, 504, 530, 506, 530, 1520, 558, 508, 534, 500, + 532, 512, 530, 484, 556, 1536, 532}; // LG 8808721 + irsend.sendRaw(rawData, 59, 38000); + irsend.makeDecodeResult(); + ASSERT_TRUE(irrecv.decode(&irsend.capture)); + EXPECT_EQ(LG, irsend.capture.decode_type); + EXPECT_EQ(28, irsend.capture.bits); + EXPECT_EQ(0x8808721, irsend.capture.value); + EXPECT_EQ(0x88, irsend.capture.address); + EXPECT_EQ(0x872, irsend.capture.command); + + irsend.reset(); + + // Resend the same code as the report is a sent code doesn't decode + // to the same message code. + irsend.sendLG(0x8808721); + irsend.makeDecodeResult(); + ASSERT_TRUE(irrecv.decode(&irsend.capture)); + EXPECT_EQ(LG, irsend.capture.decode_type); + EXPECT_EQ(28, irsend.capture.bits); + EXPECT_EQ(0x8808721, irsend.capture.value); + EXPECT_EQ(0x88, irsend.capture.address); + EXPECT_EQ(0x872, irsend.capture.command); + // The following seems to match the rawData above. + EXPECT_EQ( + "m8500s4250" + "m550s1600m550s550m550s550m550s550m550s1600" + "m550s550m550s550m550s550m550s550m550s550" + "m550s550m550s550m550s1600m550s550m550s550" + "m550s550m550s550m550s1600m550s1600m550s1600" + "m550s550m550s550m550s1600m550s550m550s550" + "m550s550m550s550m550s1600m550" + "s55550", + irsend.outputStr()); +} +