-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathtest_writeOnChange.cpp
33 lines (24 loc) · 1.09 KB
/
test_writeOnChange.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
Copyright (c) 2019 Arduino. All rights reserved.
*/
/**************************************************************************************
INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <util/CBORTestUtil.h>
#include <CBORDecoder.h>
#include <PropertyContainer.h>
/**************************************************************************************
TEST CODE
**************************************************************************************/
SCENARIO("An Arduino cloud property is marked 'write on change'", "[ArduinoCloudThing::decode]")
{
PropertyContainer property_container;
CloudInt test = 0;
addPropertyToContainer(property_container, test, "test", Permission::ReadWrite).writeOnChange();
/* [{0: "test", 2: 7}] = 81 A2 00 64 74 65 73 74 02 07 */
uint8_t const payload[] = {0x81, 0xA2, 0x00, 0x64, 0x74, 0x65, 0x73, 0x74, 0x02, 0x07};
int const payload_length = sizeof(payload) / sizeof(uint8_t);
CBORDecoder::decode(property_container, payload, payload_length);
REQUIRE(test == 7);
}