/* * Check that SetRangeToValue works */ void DmxBufferTest::testSetRangeToValue() { const uint8_t RANGE_DATA[] = {50, 50, 50, 50, 50}; DmxBuffer buffer; OLA_ASSERT_FALSE(buffer.SetRangeToValue(600, 50, 2)); unsigned int range_size = 5; OLA_ASSERT_TRUE(buffer.SetRangeToValue(0, 50, range_size)); OLA_ASSERT_EQ((unsigned int) DMX_UNIVERSE_SIZE, buffer.Size()); OLA_ASSERT_EQ(0, memcmp(RANGE_DATA, buffer.GetRaw(), range_size)); // setting outside the value range should fail buffer.Reset(); OLA_ASSERT_FALSE(buffer.SetRange(10, TEST_DATA, range_size)); }
/* * Test ToString() */ void DmxBufferTest::testToString() { DmxBuffer buffer; OLA_ASSERT_EQ(string(""), buffer.ToString()); buffer.SetFromString("1,2,3,4"); OLA_ASSERT_EQ(string("1,2,3,4"), buffer.ToString()); buffer.SetRangeToValue(0, 255, 5); OLA_ASSERT_EQ(string("255,255,255,255,255"), buffer.ToString()); }
DmxBuffer BufferFromValue(uint8_t value) { DmxBuffer buffer; buffer.SetRangeToValue(0, value, ola::DMX_UNIVERSE_SIZE); return buffer; }