add test for BinarySensor
This commit is contained in:
parent
2b23bbf178
commit
5bf3db20da
@ -193,6 +193,21 @@ void testBatterySensor(void) {
|
||||
TEST_ASSERT_EQUAL_INT(2, doc["suggested_display_precision"]);
|
||||
}
|
||||
|
||||
void testBinarySensor(void) {
|
||||
BinarySensor s("id", "a_name");
|
||||
|
||||
StaticJsonDocument<256> doc;
|
||||
s.buildConfig(doc);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(MAIN_DEVICE_ID"_id", doc["unique_id"]);
|
||||
TEST_ASSERT_EQUAL_STRING(MAIN_DEVICE_ID "/id/state", doc["state_topic"]);
|
||||
TEST_ASSERT_EQUAL_STRING("a_name", doc["name"]);
|
||||
TEST_ASSERT_EQUAL_STRING(NULL, doc["device_class"]);
|
||||
TEST_ASSERT_EQUAL_STRING(NULL, doc["entity_category"]);
|
||||
TEST_ASSERT_EQUAL_STRING(NULL, doc["value_template"]);
|
||||
TEST_ASSERT_NOT_NULL(GenericSensor::mapSensors["id"]);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(testDevice);
|
||||
@ -208,5 +223,6 @@ int main(int argc, char **argv) {
|
||||
RUN_TEST(testSwitch);
|
||||
RUN_TEST(testSwitchWithState);
|
||||
RUN_TEST(testNumber);
|
||||
RUN_TEST(testBinarySensor);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user