Make GetValueStoreKey public and add tests (#1997)

No functional changes.

GetValueStoreKey has 2 overloads and they return identical results, the math is correct, this was questioned here: https://github.com/domoticz/domoticz/issues/3727
This commit is contained in:
Peter Gebruers 2019-11-13 08:01:33 +01:00 committed by GitHub
parent 79663e1e50
commit aa29b66ea6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 14 deletions

View file

@ -75,14 +75,6 @@ namespace OpenZWave
class OPENZWAVE_EXPORT ValueID
{
friend class Manager;
friend class Driver;
friend class Node;
friend class Group;
friend class Internal::VC::Value;
friend class Internal::VC::ValueStore;
friend class Notification;
public:
/**
* Value Genres
@ -302,7 +294,7 @@ namespace OpenZWave
m_id = ((uint32) (id & 0xFFFFFFFF));
m_id1 = (uint32) (id >> 32);
}
private:
// Construct a value id for use in notifications
ValueID(uint32 const _homeId, uint8 const _nodeId) :
m_id1(0), m_homeId(_homeId)
@ -349,6 +341,8 @@ namespace OpenZWave
return key;
}
private:
// ID Packing:
// Bits
// 24-31: 8 bits. Node ID of device

View file

@ -26,15 +26,16 @@
//-----------------------------------------------------------------------------
#include "gtest/gtest.h"
#include "value_classes/ValueID.h"
using namespace OpenZWave;
extern uint16_t ozw_vers_major;
extern uint16_t ozw_vers_minor;
extern uint16_t ozw_vers_revision;
namespace OpenZWave
{
namespace Testing
{
TEST(OpenZWave, Version)
{
EXPECT_EQ(ozw_vers_major, 1);
@ -82,3 +83,42 @@ TEST(ValueID, Comparision)
ValueID(0xFFFF, (uint64)0x01),
ValueID(0xFFFF, 0x1, ValueID::ValueGenre_Basic, 0xCC, 0x02, 0x04, ValueID::ValueType_BitSet));
}
TEST(ValueID, GetStoreKey)
{
ValueID *vid1 = new ValueID(0xFFFFu, 0x1, ValueID::ValueGenre_Basic, 0xCC, 0x02, 0x04, ValueID::ValueType_BitSet);
ValueID *vid2 = new ValueID(0xFFFFu, 0x1, ValueID::ValueGenre_Basic, 0x01, 0x01, 0x01, ValueID::ValueType_BitSet);
ValueID *vid3 = new ValueID(0xFFFFu, 0x1, ValueID::ValueGenre_Basic, 0x80, 0x80, 0x80, ValueID::ValueType_BitSet);
EXPECT_EQ(vid1->GetValueStoreKey(), ValueID::GetValueStoreKey(0xCC, 0x02, 0x04));
EXPECT_EQ(vid2->GetValueStoreKey(), ValueID::GetValueStoreKey(0x01, 0x01, 0x01));
EXPECT_EQ(vid3->GetValueStoreKey(), ValueID::GetValueStoreKey(0x80, 0x80, 0x80));
EXPECT_NE(vid1->GetValueStoreKey(), vid2->GetValueStoreKey());
EXPECT_NE(vid1->GetValueStoreKey(), vid3->GetValueStoreKey());
EXPECT_NE(vid2->GetValueStoreKey(), vid3->GetValueStoreKey());
// See if we've all three contributing parts (CC, instance and index) in the mix.
EXPECT_NE(ValueID::GetValueStoreKey(0x80, 0x80, 0x80), ValueID::GetValueStoreKey(0x81, 0x80, 0x80));
EXPECT_NE(ValueID::GetValueStoreKey(0x80, 0x80, 0x80), ValueID::GetValueStoreKey(0x80, 0x81, 0x80));
EXPECT_NE(ValueID::GetValueStoreKey(0x80, 0x80, 0x80), ValueID::GetValueStoreKey(0x80, 0x80, 0x81));
ValueID *vid4 = new ValueID(0xFFFFu, 0x1, ValueID::ValueGenre_Basic, 0x81, 0x80, 0x80, ValueID::ValueType_BitSet);
ValueID *vid5 = new ValueID(0xFFFFu, 0x1, ValueID::ValueGenre_Basic, 0x80, 0x81, 0x80, ValueID::ValueType_BitSet);
ValueID *vid6 = new ValueID(0xFFFFu, 0x1, ValueID::ValueGenre_Basic, 0x80, 0x80, 0x81, ValueID::ValueType_BitSet);
EXPECT_NE(vid3->GetValueStoreKey(), vid4->GetValueStoreKey());
EXPECT_NE(vid3->GetValueStoreKey(), vid5->GetValueStoreKey());
EXPECT_NE(vid3->GetValueStoreKey(), vid6->GetValueStoreKey());
EXPECT_NE(vid4->GetValueStoreKey(), vid5->GetValueStoreKey());
EXPECT_NE(vid4->GetValueStoreKey(), vid6->GetValueStoreKey());
EXPECT_NE(vid5->GetValueStoreKey(), vid6->GetValueStoreKey());
delete vid1;
delete vid2;
delete vid3;
delete vid4;
delete vid5;
delete vid6;
}
} // namespace Testing
} // namespace OpenZWave

4
dist/openzwave.spec vendored
View file

@ -3,7 +3,7 @@
%endif
Name: openzwave
Version: 1.6.949
Version: 1.6.954
Release: 1.0%{?dist}
Summary: Sample Executables for OpenZWave
URL: http://www.openzwave.net
@ -135,7 +135,7 @@ getent group zwave >/dev/null || groupadd -f -r zwave
%changelog
* Wed May 08 2019 Justin Hammond <justin@dynam.ac> - 1.6.949
* Wed May 08 2019 Justin Hammond <justin@dynam.ac> - 1.6.954
- Update to new release of OpenZwave - 1.6
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.0-0.20180624git1e36dcc.0