Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Add unittest for getDatattypeForPath
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schildt <[email protected]>
  • Loading branch information
SebastianSchildt committed Jul 1, 2022
1 parent e683ea8 commit 2c517bc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions kuksa-val-server/test/unit-test/VssDatabaseTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,38 @@ BOOST_AUTO_TEST_CASE(applyDefaultValues_Recurse) {
}


/** getDataTypeTests **/
BOOST_AUTO_TEST_CASE(getDataTypeForSensor) {
db->initJsonTree(validFilename);
std::string path = "Vehicle.Speed";
std::string dt = db->getDatatypeForPath(VSSPath::fromVSS(path));
BOOST_TEST(dt == "int32");
}

BOOST_AUTO_TEST_CASE(getDataTypeForAttribute) {
db->initJsonTree(validFilename);
std::string path = "Vehicle/VehicleIdentification/VIN";
std::string dt = db->getDatatypeForPath(VSSPath::fromVSS(path));
BOOST_TEST(dt == "string");
}

BOOST_AUTO_TEST_CASE(getDataTypeForActuator) {
db->initJsonTree(validFilename);
std::string path = "Vehicle/Cabin/Door/Row1/Right/IsLocked";
std::string dt = db->getDatatypeForPath(VSSPath::fromVSS(path));
BOOST_TEST(dt == "boolean");
}

BOOST_AUTO_TEST_CASE(getDataTypeForBranch) {
db->initJsonTree(validFilename);
std::string path = "Vehicle/Body";
BOOST_CHECK_THROW(db->getDatatypeForPath(VSSPath::fromVSS(path)), genException);
}

BOOST_AUTO_TEST_CASE(getDataTypeForNonExistingPath) {
db->initJsonTree(validFilename);
std::string path = "Vehicle/FluxCapacitor/Charge";
BOOST_CHECK_THROW(db->getDatatypeForPath(VSSPath::fromVSS(path)), noPathFoundonTree);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 2c517bc

Please sign in to comment.