-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathtest_addPropertyReal.cpp
79 lines (56 loc) · 3.19 KB
/
test_addPropertyReal.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
Copyright (c) 2019 Arduino. All rights reserved.
*/
/**************************************************************************************
INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <PropertyContainer.h>
#include <types/CloudInt.h>
#include <types/CloudBool.h>
#include <types/CloudFloat.h>
#include <types/CloudString.h>
/**************************************************************************************
TEST CODE
**************************************************************************************/
SCENARIO("The same arduino cloud properties are added multiple times", "[ArduinoCloudThing::addPropertyReal]") {
WHEN("The same bool property is added multiple times") {
PropertyContainer property_container;
CloudBool bool_property = false;
Property * bool_property_ptr_1 = &property_container.addPropertyReal(bool_property, "bool_property", Permission::ReadWrite);
Property * bool_property_ptr_2 = &property_container.addPropertyReal(bool_property, "bool_property", Permission::ReadWrite);
THEN("No new property is added and the first added property is returned instead of a new one") {
REQUIRE(bool_property_ptr_1 == bool_property_ptr_2);
}
}
/**************************************************************************************/
WHEN("the same int property is added multiple times") {
PropertyContainer property_container;
CloudInt int_property = 1;
Property * int_property_ptr_1 = &property_container.addPropertyReal(int_property, "int_property", Permission::ReadWrite);
Property * int_property_ptr_2 = &property_container.addPropertyReal(int_property, "int_property", Permission::ReadWrite);
THEN("No new property is added and the first added property is returned instead of a new one") {
REQUIRE(int_property_ptr_1 == int_property_ptr_2);
}
}
/**************************************************************************************/
WHEN("the same float property is added multiple times") {
PropertyContainer property_container;
CloudFloat float_property = 1.0f;
Property * float_property_ptr_1 = &property_container.addPropertyReal(float_property, "float_property", Permission::ReadWrite);
Property * float_property_ptr_2 = &property_container.addPropertyReal(float_property, "float_property", Permission::ReadWrite);
THEN("No new property is added and the first added property is returned instead of a new one") {
REQUIRE(float_property_ptr_1 == float_property_ptr_2);
}
}
/**************************************************************************************/
WHEN("the same String property is added multiple times") {
PropertyContainer property_container;
CloudString str_property;
Property * str_property_ptr_1 = &property_container.addPropertyReal(str_property, "str_property", Permission::ReadWrite);
Property * str_property_ptr_2 = &property_container.addPropertyReal(str_property, "str_property", Permission::ReadWrite);
THEN("No new property is added and the first added property is returned instead of a new one") {
REQUIRE(str_property_ptr_1 == str_property_ptr_2);
}
}
}