Skip to content

Commit

Permalink
Merge pull request #536 from peternewman/coveralls
Browse files Browse the repository at this point in the history
Improve coverage of a few tests a little bit.
  • Loading branch information
nomis52 committed Nov 24, 2014
2 parents f1af4e2 + 5a464fe commit 8818716
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions common/network/InterfacePickerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void InterfacePickerTest::testChooseInterface() {
// now with one iface that doesn't match
Interface iface1;
iface1.name = "eth0";
iface1.index = 1;
OLA_ASSERT_TRUE(IPV4Address::FromString("10.0.0.1", &iface1.ip_address));
interfaces.push_back(iface1);

Expand All @@ -123,6 +124,7 @@ void InterfacePickerTest::testChooseInterface() {
// check that preferred works
Interface iface2;
iface2.name = "eth1";
iface2.index = 2;
OLA_ASSERT_TRUE(IPV4Address::FromString("192.168.1.1", &iface2.ip_address));
interfaces.push_back(iface2);

Expand All @@ -140,4 +142,12 @@ void InterfacePickerTest::testChooseInterface() {
// a invalid address should return the first one
OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, "foo"));
OLA_ASSERT_TRUE(iface1 == iface);

// now check by iface index
OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, 2));
OLA_ASSERT_TRUE(iface2 == iface);

// an invalid index should return the first one
OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, 3));
OLA_ASSERT_TRUE(iface1 == iface);
}
10 changes: 10 additions & 0 deletions common/network/NetworkUtilsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ void NetworkUtilsTest::testToFromLittleEndian() {

uint32_t v3 = 0x01020304;
OLA_ASSERT_EQ(v3, LittleEndianToHost(HostToLittleEndian(v3)));

int8_t v4 = -10;
OLA_ASSERT_EQ(v4, HostToLittleEndian(v4));
OLA_ASSERT_EQ(v4, LittleEndianToHost(HostToLittleEndian(v4)));

int16_t v5 = -0x0102;
OLA_ASSERT_EQ(v5, LittleEndianToHost(HostToLittleEndian(v5)));

int32_t v6 = -0x01020304;
OLA_ASSERT_EQ(v6, LittleEndianToHost(HostToLittleEndian(v6)));
}


Expand Down
10 changes: 10 additions & 0 deletions common/timecode/TimeCodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


using ola::timecode::TimeCode;
using std::ostringstream;
using std::string;

using ola::timecode::TIMECODE_FILM;
Expand All @@ -52,19 +53,28 @@ CPPUNIT_TEST_SUITE_REGISTRATION(TimeCodeTest);
* Test the TimeCodes work.
*/
void TimeCodeTest::testTimeCode() {
ostringstream str1;

TimeCode t1(TIMECODE_FILM, 0, 0, 0, 0);
OLA_ASSERT_EQ(TIMECODE_FILM, t1.Type());
OLA_ASSERT_EQ(static_cast<uint8_t>(0), t1.Hours());
OLA_ASSERT_EQ(static_cast<uint8_t>(0), t1.Minutes());
OLA_ASSERT_EQ(static_cast<uint8_t>(0), t1.Seconds());
OLA_ASSERT_EQ(static_cast<uint8_t>(0), t1.Frames());
OLA_ASSERT_EQ(string("00:00:00:00"), t1.AsString());
str1 << t1;
OLA_ASSERT_EQ(string("00:00:00:00"), str1.str());
OLA_ASSERT_TRUE(t1.IsValid());

ostringstream str3;

TimeCode t2(t1);
OLA_ASSERT_EQ(t1, t2);

TimeCode t3(TIMECODE_SMPTE, 10, 9, 12, 14);
OLA_ASSERT_EQ(string("10:09:12:14"), t3.AsString());
str3 << t3;
OLA_ASSERT_EQ(string("10:09:12:14"), str3.str());
OLA_ASSERT_TRUE(t3.IsValid());
OLA_ASSERT_NE(t1, t3);
t3 = t1;
Expand Down
6 changes: 6 additions & 0 deletions common/utils/DmxBufferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "ola/DmxBuffer.h"
#include "ola/testing/TestUtils.h"

using std::ostringstream;
using std::string;
using ola::DmxBuffer;

Expand Down Expand Up @@ -512,4 +513,9 @@ void DmxBufferTest::testToString() {

buffer.SetRangeToValue(0, 255, 5);
OLA_ASSERT_EQ(string("255,255,255,255,255"), buffer.ToString());

buffer.SetFromString("1,2,3,4");
ostringstream str;
str << buffer;
OLA_ASSERT_EQ(string("1,2,3,4"), str.str());
}

0 comments on commit 8818716

Please sign in to comment.