1616 TEST CODE
1717 **************************************************************************************/
1818
19- /* ***********************************************************************************/
20- SCENARIO (" Arduino Cloud Properties " , " [ArduinoCloudThing::CloudColor]" ) {
21- WHEN (" Set invalid color HSB" ) {
22- GIVEN (" CloudProtocol::V2" ) {
23-
24-
25- CloudColor color_test = CloudColor (0.0 , 0.0 , 0.0 );
26-
27- Color value_color_test = color_test.getValue ();
28- REQUIRE (value_color_test.setColorHSB (500.0 , 20.0 , 30.0 ) == false );
29-
30- }
19+ SCENARIO (" Arduino Cloud Properties " , " [ArduinoCloudThing::CloudColor]" )
20+ {
21+ WHEN (" Set invalid color HSB" )
22+ {
23+ CloudColor color_test = CloudColor (0.0 , 0.0 , 0.0 );
24+
25+ Color value_color_test = color_test.getValue ();
26+ REQUIRE (value_color_test.setColorHSB (500.0 , 20.0 , 30.0 ) == false );
3127 }
3228
33- WHEN (" Set and Get different RGB colors" ) {
34- GIVEN (" CloudProtocol::V2" ) {
29+ WHEN (" Set and Get different RGB colors" )
30+ {
31+ uint8_t r, g, b;
3532
36- uint8_t r, g, b ;
33+ CloudColor color_test = CloudColor ( 0.0 , 0.0 , 0.0 ) ;
3734
38- CloudColor color_test = CloudColor ( 0.0 , 0.0 , 0.0 );
35+ Color value_color_test = color_test. getValue ( );
3936
40- Color value_color_test = color_test.getValue ();
37+ value_color_test.setColorRGB (128 , 64 , 64 );
38+ value_color_test.getRGB (r, g, b);
4139
42- value_color_test.setColorRGB (128 , 64 , 64 );
43- value_color_test.getRGB (r, g, b);
40+ REQUIRE (r == 128 );
41+ REQUIRE (g == 64 );
42+ REQUIRE (b == 64 );
4443
45- REQUIRE (r == 128 );
46- REQUIRE (g == 64 );
47- REQUIRE (b == 64 );
44+ value_color_test.setColorRGB (126 , 128 , 64 );
45+ value_color_test.getRGB (r, g, b);
4846
49- value_color_test.setColorRGB (126 , 128 , 64 );
50- value_color_test.getRGB (r, g, b);
47+ REQUIRE (r == 126 );
48+ REQUIRE (g == 128 );
49+ REQUIRE (b == 64 );
5150
52- REQUIRE (r == 126 );
53- REQUIRE (g == 128 );
54- REQUIRE (b == 64 );
51+ value_color_test.setColorRGB (64 , 128 , 64 );
52+ value_color_test.getRGB (r, g, b);
5553
56- value_color_test.setColorRGB (64 , 128 , 64 );
57- value_color_test.getRGB (r, g, b);
54+ REQUIRE (r == 64 );
55+ REQUIRE (g == 128 );
56+ REQUIRE (b == 64 );
5857
59- REQUIRE (r == 64 );
60- REQUIRE (g == 128 );
61- REQUIRE (b == 64 );
58+ value_color_test.setColorRGB (64 , 64 , 128 );
59+ value_color_test.getRGB (r, g, b);
6260
63- value_color_test.setColorRGB (64 , 64 , 128 );
64- value_color_test.getRGB (r, g, b);
61+ REQUIRE (r == 64 );
62+ REQUIRE (g == 64 );
63+ REQUIRE (b == 128 );
6564
66- REQUIRE (r == 64 );
67- REQUIRE (g == 64 );
68- REQUIRE (b == 128 );
65+ value_color_test.setColorRGB (255 , 0 , 255 );
66+ value_color_test.getRGB (r, g, b);
6967
70- value_color_test.setColorRGB (255 , 0 , 255 );
71- value_color_test.getRGB (r, g, b);
68+ REQUIRE (r == 255 );
69+ REQUIRE (g == 0 );
70+ REQUIRE (b == 255 );
7271
73- REQUIRE (r == 255 );
74- REQUIRE (g == 0 );
75- REQUIRE (b == 255 );
72+ value_color_test.setColorRGB (0 , 0 , 0 );
73+ value_color_test.getRGB (r, g, b);
7674
77- value_color_test.setColorRGB (0 , 0 , 0 );
78- value_color_test.getRGB (r, g, b);
75+ REQUIRE (r == 0 );
76+ REQUIRE (g == 0 );
77+ REQUIRE (b == 0 );
7978
80- REQUIRE (r == 0 );
81- REQUIRE (g == 0 );
82- REQUIRE (b == 0 );
79+ value_color_test.setColorRGB (50 , 100 , 20 );
80+ value_color_test.getRGB (r, g, b);
8381
84- value_color_test.setColorRGB (50 , 100 , 20 );
85- value_color_test.getRGB (r, g, b);
82+ REQUIRE (r == 50 );
83+ REQUIRE (g == 100 );
84+ REQUIRE (b == 20 );
8685
87- REQUIRE (r == 50 );
88- REQUIRE (g == 100 );
89- REQUIRE (b == 20 );
86+ value_color_test.setColorRGB (20 , 50 , 70 );
87+ value_color_test.getRGB (r, g, b);
9088
91- value_color_test.setColorRGB (20 , 50 , 70 );
92- value_color_test.getRGB (r, g, b);
93-
94- REQUIRE (r == 20 );
95- REQUIRE (g == 50 );
96- REQUIRE (b == 70 );
97-
98- }
89+ REQUIRE (r == 20 );
90+ REQUIRE (g == 50 );
91+ REQUIRE (b == 70 );
9992 }
10093
101- WHEN (" Set HSB colors and get RGB" ) {
102- GIVEN (" CloudProtocol::V2" ) {
103- bool verify;
104- uint8_t r, g, b;
105-
106- CloudColor color_test = CloudColor (0.0 , 0.0 , 0.0 );
94+ WHEN (" Set HSB colors and get RGB" )
95+ {
96+ bool verify;
97+ uint8_t r, g, b;
10798
108- Color value_color_test = color_test. getValue ( );
99+ CloudColor color_test = CloudColor ( 0.0 , 0.0 , 0.0 );
109100
110- value_color_test.setColorHSB (240 , 50 , 50 );
111- value_color_test.getRGB (r, g, b);
112- verify = r == 64 && g == 64 && b == 128 ;
101+ Color value_color_test = color_test.getValue ();
113102
114- REQUIRE (verify);
103+ value_color_test.setColorHSB (240 , 50 , 50 );
104+ value_color_test.getRGB (r, g, b);
105+ verify = r == 64 && g == 64 && b == 128 ;
115106
116- value_color_test.setColorHSB (120 , 50 , 50 );
117- value_color_test.getRGB (r, g, b);
118- verify = r == 64 && g == 128 && b == 64 ;
107+ REQUIRE (verify);
119108
120- REQUIRE (verify);
109+ value_color_test.setColorHSB (120 , 50 , 50 );
110+ value_color_test.getRGB (r, g, b);
111+ verify = r == 64 && g == 128 && b == 64 ;
121112
122- }
113+ REQUIRE (verify);
123114 }
124115}
0 commit comments