ir_GlobalCache_test.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2017 David Conran
  2. #include "IRsend.h"
  3. #include "IRsend_test.h"
  4. #include "gtest/gtest.h"
  5. // Tests for sendGlobalCache().
  6. // Test sending a typical command wihtout a repeat.
  7. TEST(TestSendGlobalCache, NonRepeatingCode) {
  8. IRsendTest irsend(4);
  9. IRrecv irrecv(4);
  10. irsend.begin();
  11. irsend.reset();
  12. // Modified NEC TV "Power On" from Global Cache with no repeats
  13. uint16_t gc_test[71] = {38000, 1, 1, 342, 172, 21, 22, 21, 21, 21, 65, 21,
  14. 21, 21, 22, 21, 22, 21, 21, 21, 22, 21, 65, 21,
  15. 65, 21, 22, 21, 65, 21, 65, 21, 65, 21, 65, 21,
  16. 65, 21, 65, 21, 22, 21, 22, 21, 21, 21, 22, 21,
  17. 22, 21, 65, 21, 22, 21, 21, 21, 65, 21, 65, 21,
  18. 65, 21, 64, 22, 65, 21, 22, 21, 65, 21, 1519};
  19. irsend.sendGC(gc_test, 71);
  20. irsend.makeDecodeResult();
  21. EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture));
  22. EXPECT_EQ(NEC, irsend.capture.decode_type);
  23. EXPECT_EQ(kNECBits, irsend.capture.bits);
  24. EXPECT_EQ(0x20DF827D, irsend.capture.value);
  25. EXPECT_EQ(0x4, irsend.capture.address);
  26. EXPECT_EQ(0x41, irsend.capture.command);
  27. EXPECT_EQ(
  28. "m8892s4472m546s572m546s546m546s1690m546s546m546s572m546s572"
  29. "m546s546m546s572m546s1690m546s1690m546s572m546s1690m546s1690"
  30. "m546s1690m546s1690m546s1690m546s1690m546s572m546s572m546s546"
  31. "m546s572m546s572m546s1690m546s572m546s546m546s1690m546s1690"
  32. "m546s1690m546s1664m572s1690m546s572m546s1690m546s39494",
  33. irsend.outputStr());
  34. }
  35. // Test sending typical command with repeats.
  36. TEST(TestSendGlobalCache, RepeatCode) {
  37. IRsendTest irsend(4);
  38. IRrecv irrecv(4);
  39. irsend.begin();
  40. irsend.reset();
  41. // Sherwood (NEC-like) "Power On" from Global Cache with 2 repeats
  42. uint16_t gc_test[75] = {
  43. 38000, 2, 69, 341, 171, 21, 64, 21, 64, 21, 21, 21, 21, 21, 21,
  44. 21, 21, 21, 21, 21, 64, 21, 64, 21, 21, 21, 64, 21, 21, 21,
  45. 21, 21, 21, 21, 64, 21, 21, 21, 64, 21, 21, 21, 21, 21, 21,
  46. 21, 64, 21, 21, 21, 21, 21, 21, 21, 21, 21, 64, 21, 64, 21,
  47. 64, 21, 21, 21, 64, 21, 64, 21, 64, 21, 1600, 341, 85, 21, 3647};
  48. irsend.sendGC(gc_test, 75);
  49. irsend.makeDecodeResult();
  50. EXPECT_TRUE(irrecv.decodeNEC(&irsend.capture));
  51. EXPECT_EQ(NEC, irsend.capture.decode_type);
  52. EXPECT_EQ(kNECBits, irsend.capture.bits);
  53. EXPECT_EQ(0xC1A28877, irsend.capture.value);
  54. EXPECT_EQ(0x4583, irsend.capture.address);
  55. EXPECT_EQ(0x11, irsend.capture.command);
  56. EXPECT_EQ(
  57. "m8866s4446m546s1664m546s1664m546s546m546s546m546s546m546s546"
  58. "m546s546m546s1664m546s1664m546s546m546s1664m546s546m546s546"
  59. "m546s546m546s1664m546s546m546s1664m546s546m546s546m546s546"
  60. "m546s1664m546s546m546s546m546s546m546s546m546s1664m546s1664"
  61. "m546s1664m546s546m546s1664m546s1664m546s1664m546s41600"
  62. "m8866s2210m546s94822"
  63. "m8866s2210m546s94822",
  64. irsend.outputStr());
  65. }