Skip to content

Commit

Permalink
tested exceptions and getSource/Destination
Browse files Browse the repository at this point in the history
  • Loading branch information
Grufoony committed Jul 9, 2023
1 parent 1ac3c5a commit 3876d1b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1308,12 +1308,14 @@ TEST_CASE("Vehicle") {
TEST_CASE("Street") {
SUBCASE("Constructor exceptions") {
/*This test tests if the constructor throws an exception
The constructor should throw an exception if the length is negative or if
the index is negative
The constructor should throw an exception one of the arguments is negative
GIVEN: the constructor is called with length -10 or index -1
WHEN: the Street is created
THEN: the function should throw an exception
*/
CHECK_THROWS(Street(-3, 1, 1., 0));
CHECK_THROWS(Street(0, -1, 1., 0));
CHECK_THROWS(Street(-5, -9, 3., 0));
CHECK_THROWS(Street(0, 1, -10., 0));
CHECK_THROWS(Street(0, 1, 10., -1));
}
Expand Down Expand Up @@ -1342,6 +1344,18 @@ TEST_CASE("Street") {
CHECK(s.getVehicleDensity() == doctest::Approx(0.));
CHECK(s.getNLanes() == 1);
}
SUBCASE("origin and destination") {
/*This test tests if the getOrigin and getDestination functions work
correctly The getOrigin function should return the origin of the street The
getDestination function should return the destination of the street
GIVEN: the constructor is called with origin 3 and destination 9
WHEN: the street is created
THEN: the street should have origin 0 and destination 1
*/
Street s(3, 9, 10., 0);
CHECK(s.getOrigin() == 3);
CHECK(s.getDestination() == 9);
}
SUBCASE("setNLanes exception") {
/*This test tests if the setNLanes function throws an exception
The setNLanes function should throw an exception if the number of lanes is
Expand Down

0 comments on commit 3876d1b

Please sign in to comment.