Skip to content

Commit 11e77ea

Browse files
committed
Add writeOnChange testcase
1 parent 4cf7a34 commit 11e77ea

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

extras/test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set(TEST_SRCS
4242
src/test_readOnly.cpp
4343
src/test_writeOnly.cpp
4444
src/test_writeOnDemand.cpp
45+
src/test_writeOnChange.cpp
4546
)
4647

4748
set(TEST_UTIL_SRCS
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright (c) 2019 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
INCLUDE
7+
**************************************************************************************/
8+
9+
#include <catch.hpp>
10+
11+
#include <util/CBORTestUtil.h>
12+
13+
#include <CBORDecoder.h>
14+
#include <PropertyContainer.h>
15+
16+
/**************************************************************************************
17+
TEST CODE
18+
**************************************************************************************/
19+
20+
SCENARIO("An Arduino cloud property is marked 'write on change'", "[ArduinoCloudThing::decode]")
21+
{
22+
PropertyContainer property_container;
23+
24+
CloudInt test = 0;
25+
addPropertyToContainer(property_container, test, "test", Permission::ReadWrite).writeOnChange();
26+
27+
/* [{0: "test", 2: 7}] = 81 A2 00 64 74 65 73 74 02 07 */
28+
uint8_t const payload[] = {0x81, 0xA2, 0x00, 0x64, 0x74, 0x65, 0x73, 0x74, 0x02, 0x07};
29+
int const payload_length = sizeof(payload) / sizeof(uint8_t);
30+
CBORDecoder::decode(property_container, payload, payload_length);
31+
32+
REQUIRE(test == 7);
33+
}

0 commit comments

Comments
 (0)