mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
fix: edit ops second review findings
- A group's sunSensor and a shade's flags are refused by name: the routes don't set them. - setPaired needs paired, and without a shade id it is a bad request. - groupOptions' payload is parsed in ProtoEdits (parseReadPayload). - The assembler's mutex is static, so creating it can't fail. - protoIsReadOp and protoIsShadeOp are gone; the tests use protoOpKind. - Native tests for missing(), offeredRemoteAddress and the edit ops against the TYPE table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8fa087aa89
commit
970256e7f6
13 changed files with 107 additions and 34 deletions
|
|
@ -31,6 +31,12 @@ static void test_free_remote_address_skips_every_taken_one() {
|
|||
TEST_ASSERT_EQUAL_UINT32(104, freeRemoteAddress(101, used, 4));
|
||||
TEST_ASSERT_EQUAL_UINT32(100, freeRemoteAddress(100, used, 4));
|
||||
}
|
||||
static void test_a_new_one_is_offered_the_starting_address_plus_its_id() {
|
||||
TEST_ASSERT_EQUAL_UINT32(1005, offeredRemoteAddress(1000, 5, nullptr, 0));
|
||||
// Taken by another shade or group, so the next free one.
|
||||
const uint32_t used[] = { 1006, 1005 };
|
||||
TEST_ASSERT_EQUAL_UINT32(1007, offeredRemoteAddress(1000, 5, used, 2));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* Lists
|
||||
|
|
@ -137,6 +143,23 @@ static void test_255_means_no_pin() {
|
|||
/*********************************************************************
|
||||
* What protocol 2 clients are sent after an edit
|
||||
********************************************************************/
|
||||
/*********************************************************************
|
||||
* Results
|
||||
********************************************************************/
|
||||
static void test_a_missing_id_is_not_found() {
|
||||
const edit_result_t r = edit_result_t::missing("Shade Id not found.");
|
||||
TEST_ASSERT_FALSE(r.ok);
|
||||
TEST_ASSERT_TRUE(r.notFound);
|
||||
TEST_ASSERT_EQUAL_STRING("Shade Id not found.", r.desc);
|
||||
}
|
||||
static void test_any_other_refusal_is_not_not_found() {
|
||||
const edit_result_t r = edit_result_t::error("No shade id was supplied.", 3);
|
||||
TEST_ASSERT_FALSE(r.ok);
|
||||
TEST_ASSERT_FALSE(r.notFound);
|
||||
TEST_ASSERT_EQUAL_INT8(3, r.code);
|
||||
TEST_ASSERT_FALSE(edit_result_t().notFound);
|
||||
}
|
||||
|
||||
static edit_result_t resultFor(uint8_t id, uint8_t shadeId = 0) {
|
||||
edit_result_t r;
|
||||
r.id = id;
|
||||
|
|
@ -203,6 +226,9 @@ int main(int argc, char **argv) {
|
|||
RUN_TEST(test_first_free_id_is_0_when_every_one_is_taken);
|
||||
RUN_TEST(test_next_sort_order_goes_after_the_last);
|
||||
RUN_TEST(test_free_remote_address_skips_every_taken_one);
|
||||
RUN_TEST(test_a_new_one_is_offered_the_starting_address_plus_its_id);
|
||||
RUN_TEST(test_a_missing_id_is_not_found);
|
||||
RUN_TEST(test_any_other_refusal_is_not_not_found);
|
||||
RUN_TEST(test_add_goes_into_the_first_empty_slot);
|
||||
RUN_TEST(test_adding_one_already_there_changes_nothing);
|
||||
RUN_TEST(test_adding_to_a_full_list_fails);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue