/*
 * Test the StringToDmx function
 */
void DmxBufferTest::testStringToDmx() {
  string input = "1,2,3,4";
  uint8_t expected1[] = {1, 2, 3, 4};
  runStringToDmx(input, DmxBuffer(expected1, sizeof(expected1)));

  input = "a,b,c,d";
  uint8_t expected2[] = {0, 0, 0, 0};
  runStringToDmx(input, DmxBuffer(expected2, sizeof(expected2)));

  input = "a,b,c,";
  uint8_t expected3[] = {0, 0, 0, 0};
  runStringToDmx(input, DmxBuffer(expected3, sizeof(expected3)));

  input = "255,,,";
  uint8_t expected4[] = {255, 0, 0, 0};
  runStringToDmx(input, DmxBuffer(expected4, sizeof(expected4)));

  input = "255,,,10";
  uint8_t expected5[] = {255, 0, 0, 10};
  runStringToDmx(input, DmxBuffer(expected5, sizeof(expected5)));

  input = " 266,,,10  ";
  uint8_t expected6[] = {10, 0, 0, 10};
  runStringToDmx(input, DmxBuffer(expected6, sizeof(expected6)));

  input = "";
  uint8_t expected7[] = {};
  runStringToDmx(input, DmxBuffer(expected7, sizeof(expected7)));
}
Example #2
0
    DmxBuffer buffer;
    buffer.SetRangeToValue(0, value, ola::DMX_UNIVERSE_SIZE);
    return buffer;
}


TestState s1("Single Source Send",
             new NodeSimpleSend(20),
             new NodeInactive(),
             "512 x 20",
             BufferFromValue(20));
TestState s2("Single Source Timeout",
             new NodeInactive(),
             new NodeInactive(),
             "Loss of data after 2.5s",
             DmxBuffer());
TestState s3("Single Source Send",
             new NodeSimpleSend(10),
             new NodeInactive(),
             "512 x 10",
             BufferFromValue(10));
TestState s4("Single Source Terminate",
             new NodeTerminate(),
             new NodeInactive(),
             "Immediate loss of data",
             DmxBuffer());
TestState s5("Single Source Send",
             new NodeSimpleSend(30),
             new NodeInactive(),
             "512 x 30",
             BufferFromValue(30));
 void Check(SimpleRpcController *controller,
            ola::proto::DmxData *reply) {
   OLA_ASSERT_FALSE(controller->Failed());
   OLA_ASSERT(DmxBuffer(SAMPLE_DMX_DATA, sizeof(SAMPLE_DMX_DATA)) ==
                  DmxBuffer(reply->data()));
 }
 void Check(SimpleRpcController *controller,
            ola::proto::DmxData *reply) {
   DmxBuffer empty_buffer;
   OLA_ASSERT_FALSE(controller->Failed());
   OLA_ASSERT(empty_buffer == DmxBuffer(reply->data()));
 }