Skip to content

Removing obsolete identifier CloudProtocol::V2 from test code #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions extras/test/src/Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ static unsigned long current_millis = 0;
PUBLIC FUNCTIONS
******************************************************************************/

void set_millis(unsigned long const millis) {
void set_millis(unsigned long const millis)
{
current_millis = millis;
}

unsigned long millis() {
unsigned long millis()
{
return current_millis;
}
143 changes: 67 additions & 76 deletions extras/test/src/test_CloudColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,109 +16,100 @@
TEST CODE
**************************************************************************************/

/************************************************************************************/
SCENARIO("Arduino Cloud Properties ", "[ArduinoCloudThing::CloudColor]") {
WHEN("Set invalid color HSB") {
GIVEN("CloudProtocol::V2") {


CloudColor color_test = CloudColor(0.0, 0.0, 0.0);

Color value_color_test = color_test.getValue();
REQUIRE(value_color_test.setColorHSB(500.0, 20.0, 30.0) == false);

}
SCENARIO("Arduino Cloud Properties ", "[ArduinoCloudThing::CloudColor]")
{
WHEN("Set invalid color HSB")
{
CloudColor color_test = CloudColor(0.0, 0.0, 0.0);

Color value_color_test = color_test.getValue();
REQUIRE(value_color_test.setColorHSB(500.0, 20.0, 30.0) == false);
}

WHEN("Set and Get different RGB colors") {
GIVEN("CloudProtocol::V2") {
WHEN("Set and Get different RGB colors")
{
uint8_t r, g, b;

uint8_t r, g, b;
CloudColor color_test = CloudColor(0.0, 0.0, 0.0);

CloudColor color_test = CloudColor(0.0, 0.0, 0.0);
Color value_color_test = color_test.getValue();

Color value_color_test = color_test.getValue();
value_color_test.setColorRGB(128, 64, 64);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(128, 64, 64);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 128);
REQUIRE(g == 64);
REQUIRE(b == 64);

REQUIRE(r == 128);
REQUIRE(g == 64);
REQUIRE(b == 64);
value_color_test.setColorRGB(126, 128, 64);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(126, 128, 64);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 126);
REQUIRE(g == 128);
REQUIRE(b == 64);

REQUIRE(r == 126);
REQUIRE(g == 128);
REQUIRE(b == 64);
value_color_test.setColorRGB(64, 128, 64);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(64, 128, 64);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 64);
REQUIRE(g == 128);
REQUIRE(b == 64);

REQUIRE(r == 64);
REQUIRE(g == 128);
REQUIRE(b == 64);
value_color_test.setColorRGB(64, 64, 128);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(64, 64, 128);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 64);
REQUIRE(g == 64);
REQUIRE(b == 128);

REQUIRE(r == 64);
REQUIRE(g == 64);
REQUIRE(b == 128);
value_color_test.setColorRGB(255, 0, 255);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(255, 0, 255);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 255);
REQUIRE(g == 0);
REQUIRE(b == 255);

REQUIRE(r == 255);
REQUIRE(g == 0);
REQUIRE(b == 255);
value_color_test.setColorRGB(0, 0, 0);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(0, 0, 0);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 0);
REQUIRE(g == 0);
REQUIRE(b == 0);

REQUIRE(r == 0);
REQUIRE(g == 0);
REQUIRE(b == 0);
value_color_test.setColorRGB(50, 100, 20);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(50, 100, 20);
value_color_test.getRGB(r, g, b);
REQUIRE(r == 50);
REQUIRE(g == 100);
REQUIRE(b == 20);

REQUIRE(r == 50);
REQUIRE(g == 100);
REQUIRE(b == 20);
value_color_test.setColorRGB(20, 50, 70);
value_color_test.getRGB(r, g, b);

value_color_test.setColorRGB(20, 50, 70);
value_color_test.getRGB(r, g, b);

REQUIRE(r == 20);
REQUIRE(g == 50);
REQUIRE(b == 70);

}
REQUIRE(r == 20);
REQUIRE(g == 50);
REQUIRE(b == 70);
}

WHEN("Set HSB colors and get RGB") {
GIVEN("CloudProtocol::V2") {
bool verify;
uint8_t r, g, b;

CloudColor color_test = CloudColor(0.0, 0.0, 0.0);
WHEN("Set HSB colors and get RGB")
{
bool verify;
uint8_t r, g, b;

Color value_color_test = color_test.getValue();
CloudColor color_test = CloudColor(0.0, 0.0, 0.0);

value_color_test.setColorHSB(240, 50, 50);
value_color_test.getRGB(r, g, b);
verify = r == 64 && g == 64 && b == 128;
Color value_color_test = color_test.getValue();

REQUIRE(verify);
value_color_test.setColorHSB(240, 50, 50);
value_color_test.getRGB(r, g, b);
verify = r == 64 && g == 64 && b == 128;

value_color_test.setColorHSB(120, 50, 50);
value_color_test.getRGB(r, g, b);
verify = r == 64 && g == 128 && b == 64;
REQUIRE(verify);

REQUIRE(verify);
value_color_test.setColorHSB(120, 50, 50);
value_color_test.getRGB(r, g, b);
verify = r == 64 && g == 128 && b == 64;

}
REQUIRE(verify);
}
}
45 changes: 31 additions & 14 deletions extras/test/src/test_CloudLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
TEST CODE
**************************************************************************************/

SCENARIO("Tesing cloud type 'Location' Ctor", "[Location::Location]") {
WHEN("A Location(1.0f, 2.0f) is being instantiated") {
SCENARIO("Tesing cloud type 'Location' Ctor", "[Location::Location]")
{
WHEN("A Location(1.0f, 2.0f) is being instantiated")
{
Location loc(1.0f, 2.0f);
THEN("The member variable 'lat' should be 1.0f") {
REQUIRE(loc.lat == 1.0f);
Expand All @@ -28,11 +30,14 @@ SCENARIO("Tesing cloud type 'Location' Ctor", "[Location::Location]") {

/**************************************************************************************/

SCENARIO("Tesing cloud type 'Location' assignment operator", "[Location::operator =]") {
SCENARIO("Tesing cloud type 'Location' assignment operator", "[Location::operator =]")
{
Location loc1(1.0f, 2.0f),
loc2(3.0f, 4.0f);
loc1 = loc2;
WHEN("One location is assigned to the other") {

WHEN("One location is assigned to the other")
{
THEN("The coordinates of the second location should be assigned to the first") {
REQUIRE(loc1.lat == 3.0f);
REQUIRE(loc1.lon == 4.0f);
Expand All @@ -42,11 +47,14 @@ SCENARIO("Tesing cloud type 'Location' assignment operator", "[Location::operato

/**************************************************************************************/

SCENARIO("Tesing cloud type 'Location' operator -", "[Location::operator -]") {
SCENARIO("Tesing cloud type 'Location' operator -", "[Location::operator -]")
{
Location loc1(1.0f, 2.0f),
loc2(3.0f, 4.0f);
Location loc3 = loc1 - loc2;
WHEN("One location is subtracted from the other") {

WHEN("One location is subtracted from the other")
{
THEN("The result should be calculated according the rule lon3 = lon1 - lon2, lat3 = lat1 - lat2") {
REQUIRE(loc3.lat == loc1.lat - loc2.lat);
REQUIRE(loc3.lon == loc1.lon - loc2.lon);
Expand All @@ -56,17 +64,21 @@ SCENARIO("Tesing cloud type 'Location' operator -", "[Location::operator -]") {

/**************************************************************************************/

SCENARIO("Tesing cloud type 'Location' comparison operator ==", "[Location::operator ==]") {
SCENARIO("Tesing cloud type 'Location' comparison operator ==", "[Location::operator ==]")
{
Location loc1(1.0f, 2.0f),
loc2(3.0f, 4.0f),
loc3(1.0f, 2.0f);
WHEN("Two locations are identical (lat as well as lon)") {

WHEN("Two locations are identical (lat as well as lon)")
{
THEN("The comparison operation should return true") {
REQUIRE((loc1 == loc3) == true);
}
}

WHEN("Two locations are not identical (either lat or lon do not match)") {
WHEN("Two locations are not identical (either lat or lon do not match)")
{
THEN("The comparison operation should return false") {
REQUIRE((loc1 == loc2) == false);
}
Expand All @@ -75,17 +87,21 @@ SCENARIO("Tesing cloud type 'Location' comparison operator ==", "[Location::oper

/**************************************************************************************/

SCENARIO("Tesing cloud type 'Location' comparison operator !=", "[Location::operator !=]") {
SCENARIO("Tesing cloud type 'Location' comparison operator !=", "[Location::operator !=]")
{
Location loc1(1.0f, 2.0f),
loc2(3.0f, 4.0f),
loc3(1.0f, 2.0f);
WHEN("Two locations are identical (lat as well as lon)") {

WHEN("Two locations are identical (lat as well as lon)")
{
THEN("The comparison operation should return false") {
REQUIRE((loc1 != loc3) == false);
}
}

WHEN("Two locations are not identical (either lat or lon do not match)") {
WHEN("Two locations are not identical (either lat or lon do not match)")
{
THEN("The comparison operation should return true") {
REQUIRE((loc1 != loc2) == true);
}
Expand All @@ -94,9 +110,10 @@ SCENARIO("Tesing cloud type 'Location' comparison operator !=", "[Location::oper

/**************************************************************************************/

SCENARIO("Tesing cloud type 'Location' function distance for calculating euclidean 2d distance between two points", "[Location::distance]") {
SCENARIO("Tesing cloud type 'Location' function distance for calculating euclidean 2d distance between two points", "[Location::distance]")
{
Location loc1(0.0f, 0.0f),
loc2(1.0f, 1.0f);

REQUIRE(Location::distance(loc1, loc2) == sqrt(2.0f));
}
}
15 changes: 10 additions & 5 deletions extras/test/src/test_addPropertyReal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
TEST CODE
**************************************************************************************/

SCENARIO("The same arduino cloud properties are added multiple times", "[ArduinoCloudThing::addPropertyToContainer]") {
WHEN("The same bool property is added multiple times") {
SCENARIO("The same arduino cloud properties are added multiple times", "[ArduinoCloudThing::addPropertyToContainer]")
{
WHEN("The same bool property is added multiple times")
{
PropertyContainer property_container;

CloudBool bool_property = false;
Expand All @@ -34,7 +36,8 @@ SCENARIO("The same arduino cloud properties are added multiple times", "[Arduino

/**************************************************************************************/

WHEN("the same int property is added multiple times") {
WHEN("the same int property is added multiple times")
{
PropertyContainer property_container;

CloudInt int_property = 1;
Expand All @@ -49,7 +52,8 @@ SCENARIO("The same arduino cloud properties are added multiple times", "[Arduino

/**************************************************************************************/

WHEN("the same float property is added multiple times") {
WHEN("the same float property is added multiple times")
{
PropertyContainer property_container;

CloudFloat float_property = 1.0f;
Expand All @@ -64,7 +68,8 @@ SCENARIO("The same arduino cloud properties are added multiple times", "[Arduino

/**************************************************************************************/

WHEN("the same String property is added multiple times") {
WHEN("the same String property is added multiple times")
{
PropertyContainer property_container;

CloudString str_property;
Expand Down
Loading