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

Commit 936ca7b

Browse files
committed
Refined unit tests
1 parent 6c4f44c commit 936ca7b

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

test/src/test_CloudColor.cpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,46 +41,59 @@ SCENARIO("Arduino Cloud Properties ", "[ArduinoCloudThing::CloudColor]") {
4141

4242
value_color_test.setColorRGB(128, 64, 64);
4343
value_color_test.getRGB(r, g, b);
44-
verify = r == 128 && g == 64 && b == 64;
4544

46-
REQUIRE(verify);
45+
REQUIRE(r == 128);
46+
REQUIRE(g == 64);
47+
REQUIRE(b == 64);
4748

4849
value_color_test.setColorRGB(126, 128, 64);
4950
value_color_test.getRGB(r, g, b);
50-
verify = r == 126 && g == 128 && b == 64;
5151

52-
REQUIRE(verify);
52+
REQUIRE(r == 126);
53+
REQUIRE(g == 128);
54+
REQUIRE(b == 64);
5355

5456
value_color_test.setColorRGB(64, 128, 64);
5557
value_color_test.getRGB(r, g, b);
56-
verify = r == 64 && g == 128 && b == 64;
5758

58-
REQUIRE(verify);
59+
REQUIRE(r == 64);
60+
REQUIRE(g == 128);
61+
REQUIRE(b == 64);
5962

6063
value_color_test.setColorRGB(64, 64, 128);
6164
value_color_test.getRGB(r, g, b);
62-
verify = r == 64 && g == 64 && b == 128;
6365

64-
REQUIRE(verify);
66+
REQUIRE(r == 64);
67+
REQUIRE(g == 64);
68+
REQUIRE(b == 128);
6569

6670
value_color_test.setColorRGB(255, 0, 255);
6771
value_color_test.getRGB(r, g, b);
68-
verify = r == 255 && g == 0 && b == 255;
6972

70-
REQUIRE(verify);
73+
REQUIRE(r == 255);
74+
REQUIRE(g == 0);
75+
REQUIRE(b == 255);
7176

7277
value_color_test.setColorRGB(0, 0, 0);
7378
value_color_test.getRGB(r, g, b);
74-
verify = r == 0 && g == 0 && b == 0;
7579

76-
REQUIRE(verify);
80+
REQUIRE(r == 0);
81+
REQUIRE(g == 0);
82+
REQUIRE(b == 0);
7783

7884
value_color_test.setColorRGB(50, 100, 20);
7985
value_color_test.getRGB(r, g, b);
80-
verify = r == 50 && g == 100 && b == 20;
8186

82-
REQUIRE(verify);
87+
REQUIRE(r == 50);
88+
REQUIRE(g == 100);
89+
REQUIRE(b == 20);
90+
91+
value_color_test.setColorRGB(20, 50, 70);
92+
value_color_test.getRGB(r, g, b);
8393

94+
REQUIRE(r == 20);
95+
REQUIRE(g == 50);
96+
REQUIRE(b == 70);
8497

8598
}
8699
}

test/src/test_decode.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ SCENARIO("Arduino Cloud Properties are decoded", "[ArduinoCloudThing::decode]")
125125
thing.decode(payload, sizeof(payload) / sizeof(uint8_t));
126126
Location location_compare = Location(2, 3);
127127
Location value_location_test = location_test.getValue();
128-
bool verify = (value_location_test == location_compare);
129-
REQUIRE(verify);
128+
REQUIRE(value_location_test.lat == location_compare.lat);
129+
REQUIRE(value_location_test.lon == location_compare.lon);
130130
}
131131
}
132132

@@ -148,17 +148,10 @@ SCENARIO("Arduino Cloud Properties are decoded", "[ArduinoCloudThing::decode]")
148148
Color color_compare = Color(2.0, 2.0, 2.0);
149149
Color value_color_test = color_test.getValue();
150150
bool verify = (value_color_test == color_compare);
151-
152-
CloudColor Color_RGB = CloudColor(0.0, 0.0, 0.0);
153-
Color c = Color_RGB.getValue();
154-
c.setColorRGB(20, 50, 70);
155-
Color_RGB = c;
156-
uint8_t r, g, b;
157-
c.getRGB(r, g, b);
158-
bool rgb = 20 == r && 50 == g && 70 == b;
159-
160-
REQUIRE(rgb);
161151
REQUIRE(verify);
152+
REQUIRE(value_color_test.hue == color_compare.hue);
153+
REQUIRE(value_color_test.sat == color_compare.sat);
154+
REQUIRE(value_color_test.bri == color_compare.bri);
162155
}
163156
}
164157

0 commit comments

Comments
 (0)