Skip to content

Commit ad74aa9

Browse files
committed
add test
1 parent 45d819c commit ad74aa9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

extras/test/src/test_command_encode.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,4 +979,34 @@ SCENARIO("Test the encoding of command messages") {
979979
REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0);
980980
}
981981
}
982+
983+
WHEN("Encode the DeviceNetConfigCmdUp message with Notecard")
984+
{
985+
DeviceNetConfigCmdUp command;
986+
command.c.id = CommandId::DeviceNetConfigCmdUpId;
987+
988+
command.params.type = NetworkAdapter::NOTECARD;
989+
990+
uint8_t buffer[512];
991+
size_t bytes_encoded = sizeof(buffer);
992+
993+
CBORMessageEncoder encoder;
994+
MessageEncoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded);
995+
996+
uint8_t expected_result[] = {
997+
0xda, 0x00, 0x01, 0x11, 0x00, 0x81,
998+
0x08
999+
};
1000+
1001+
// Test the encoding is
1002+
// DA 00011100 # tag(73728)
1003+
// 81 # array(1)
1004+
// 08 # unsigned(8)
1005+
1006+
THEN("The encoding is successful") {
1007+
REQUIRE(err == MessageEncoder::Status::Complete);
1008+
REQUIRE(bytes_encoded == sizeof(expected_result));
1009+
REQUIRE(memcmp(buffer, expected_result, sizeof(expected_result)) == 0);
1010+
}
1011+
}
9821012
}

0 commit comments

Comments
 (0)