Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 51f84ee

Browse files
ilcatoaentinger
authored andcommitted
Added encode unit test for CloudTelevision
1 parent 133070a commit 51f84ee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/src/test_encode.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ SCENARIO("Arduino Cloud Properties are encoded", "[ArduinoCloudThing::encode]")
149149

150150
/************************************************************************************/
151151

152+
WHEN("A 'Television' property is added") {
153+
GIVEN("CloudProtocol::V2") {
154+
ArduinoCloudThing thing;
155+
thing.begin();
156+
encode(thing);
157+
158+
CloudTelevision tv_test = CloudTelevision(true, 50, false, PlaybackCommands::Play, InputValue::TV, 7);
159+
thing.addPropertyReal(tv_test, "test", Permission::ReadWrite);
160+
161+
/* [{0: "test:swi", 4: true},{0: "test:vol", 2: 50},{0: "test:mut", 2: false},{0: "test:pbc", 2: 3},{0: "test:inp", 2: 55},{0: "test:cha", 2: 7}] = 86 A2 00 68 74 65 73 74 3A 73 77 69 04 F5 A2 00 68 74 65 73 74 3A 76 6F 6C 02 18 32 A2 00 68 74 65 73 74 3A 6D 75 74 02 F4 A2 00 68 74 65 73 74 3A 70 62 63 02 03 A2 00 68 74 65 73 74 3A 69 6E 70 02 18 37 A2 00 68 74 65 73 74 3A 63 68 61 02 07 */
162+
std::vector<uint8_t> const expected = {0x86, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x73, 0x77, 0x69, 0x04, 0xF5, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x76, 0x6F, 0x6C, 0x02, 0x18, 0x32, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x6D, 0x75, 0x74, 0x02, 0xF4, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x70, 0x62, 0x63, 0x02, 0x03, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x69, 0x6E, 0x70, 0x02, 0x18, 0x37, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x63, 0x68, 0x61, 0x02, 0x07 };
163+
std::vector<uint8_t> const actual = encode(thing);
164+
REQUIRE(actual == expected);
165+
}
166+
}
167+
168+
/************************************************************************************/
169+
152170
WHEN("A 'DimmedLight' property is added") {
153171
GIVEN("CloudProtocol::V2") {
154172
ArduinoCloudThing thing;

0 commit comments

Comments
 (0)