mirror of
https://github.com/alexhopeoconnor/arduino-home-assistant.git
synced 2026-10-04 02:48:13 +10:00
* added test for maximum device types * fix max device types check
This commit is contained in:
+1
-1
@@ -185,7 +185,7 @@ bool HAMqtt::isConnected() const
|
||||
|
||||
void HAMqtt::addDeviceType(HABaseDeviceType* deviceType)
|
||||
{
|
||||
if (_devicesTypesNb + 1 >= _maxDevicesTypesNb) {
|
||||
if (_devicesTypesNb + 1 > _maxDevicesTypesNb) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,16 @@ AHA_TEST(BaseDeviceTypeTest, register_mqtt_type) {
|
||||
assertEqual(&deviceType, mqtt.getDevicesTypes()[0]);
|
||||
}
|
||||
|
||||
// TODO it would be better to place this test in HAMqtt related test. Since there is no one yet, I leave it here
|
||||
AHA_TEST(BaseDeviceTypeTest, maximum_number_of_device_types) {
|
||||
HADevice device(testDeviceId);
|
||||
HAMqtt mqtt(nullptr, device, 1);
|
||||
DummyDeviceType deviceType(AHATOFSTR(ComponentNameStr), testUniqueId);
|
||||
|
||||
assertEqual((uint8_t)1, mqtt.getDevicesTypesNb());
|
||||
assertEqual(&deviceType, mqtt.getDevicesTypes()[0]);
|
||||
}
|
||||
|
||||
AHA_TEST(BaseDeviceTypeTest, default_name) {
|
||||
DummyDeviceType deviceType(AHATOFSTR(ComponentNameStr), testUniqueId);
|
||||
assertEqual((const char*)nullptr, deviceType.getName());
|
||||
|
||||
Reference in New Issue
Block a user