Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion common/messaging/DescriptorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ void DescriptorTest::testIntervalsAndLabels() {
UInt16FieldDescriptor::LabeledValues labels;
labels["dozen"] = 12;
labels["bakers_dozen"] = 13;
labels["special"] = 15;

UInt16FieldDescriptor uint16_descriptor("uint16", intervals, labels);

Expand All @@ -360,7 +361,8 @@ void DescriptorTest::testIntervalsAndLabels() {
OLA_ASSERT_TRUE(uint16_descriptor.IsValid(12));
OLA_ASSERT_TRUE(uint16_descriptor.IsValid(13));
OLA_ASSERT_TRUE(uint16_descriptor.IsValid(14));
OLA_ASSERT_FALSE(uint16_descriptor.IsValid(15));
OLA_ASSERT_TRUE(uint16_descriptor.IsValid(15));
OLA_ASSERT_FALSE(uint16_descriptor.IsValid(16));
OLA_ASSERT_FALSE(uint16_descriptor.IsValid(255));
OLA_ASSERT_FALSE(uint16_descriptor.IsValid(65535));

Expand All @@ -371,6 +373,8 @@ void DescriptorTest::testIntervalsAndLabels() {
OLA_ASSERT_EQ(static_cast<uint16_t>(12), value);
OLA_ASSERT_TRUE(uint16_descriptor.LookupLabel("bakers_dozen", &value));
OLA_ASSERT_EQ(static_cast<uint16_t>(13), value);
OLA_ASSERT_TRUE(uint16_descriptor.LookupLabel("special", &value));
OLA_ASSERT_EQ(static_cast<uint16_t>(15), value);
OLA_ASSERT_FALSE(uint16_descriptor.LookupLabel("twenty", &value));

// check LookupValue
Expand Down
6 changes: 6 additions & 0 deletions include/ola/messaging/Descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ class IntegerFieldDescriptor: public FieldDescriptor {
if (value >= iter->first && value <= iter->second)
return true;
}

typename LabeledValues::const_iterator label_iter = m_labels.begin();
for (; label_iter != m_labels.end(); ++label_iter) {
if (value == label_iter->second)
return true;
}
return false;
}

Expand Down