Skip to content

Commit

Permalink
Changed CHECK to REQUIRE in some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mesozoic-drones committed May 1, 2020
1 parent 7f6f960 commit 90a89d7
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions tests/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TEST_SUITE_BEGIN("Handling time GTFS fields");
TEST_CASE("Time in H:MM:SS format")
{
Time stop_time("0:19:00");
CHECK(stop_time.is_provided());
REQUIRE(stop_time.is_provided());
CHECK_EQ(stop_time.get_hh_mm_ss(), std::make_tuple(0, 19, 0));
CHECK_EQ(stop_time.get_raw_time(), "0:19:00");
CHECK_EQ(stop_time.get_total_seconds(), 19 * 60);
Expand Down Expand Up @@ -130,23 +130,23 @@ TEST_SUITE_BEGIN("Csv parsing");
TEST_CASE("Record with empty values")
{
const auto res = CsvParser::split_record(",, ,");
CHECK_EQ(res.size(), 4);
REQUIRE_EQ(res.size(), 4);
for (const auto & token : res)
CHECK(token.empty());
}

TEST_CASE("Header with UTF BOM")
{
const auto res = CsvParser::split_record("\xef\xbb\xbfroute_id, agency_id", true);
CHECK_EQ(res.size(), 2);
REQUIRE_EQ(res.size(), 2);
CHECK_EQ(res[0], "route_id");
CHECK_EQ(res[1], "agency_id");
}

TEST_CASE("Quotation marks")
{
const auto res = CsvParser::split_record(R"(27681 ,,"Sisters, OR",,"44.29124",1)");
CHECK_EQ(res.size(), 6);
REQUIRE_EQ(res.size(), 6);
CHECK_EQ(res[2], "Sisters, OR");
CHECK_EQ(res[4], "44.29124");
CHECK_EQ(res[5], "1");
Expand All @@ -158,30 +158,30 @@ TEST_SUITE_BEGIN("Read");
// https://developers.google.com/transit/gtfs/examples/gtfs-feed
TEST_CASE("Empty container before parsing")
{
Feed feed("data/San Francisco Municipal Transportation Agency");
CHECK(feed.get_agencies().empty());
auto agency = feed.get_agency("10");
Feed feed("data/non_existing_dir");
REQUIRE(feed.get_agencies().empty());
auto agency = feed.get_agency("agency_10");
CHECK(!agency);
}

TEST_CASE("Transfers")
{
Feed feed("data/sample_feed");
auto res = feed.read_transfers();
CHECK_EQ(res.code, ResultCode::ERROR_FILE_ABSENT);
REQUIRE_EQ(res.code, ResultCode::ERROR_FILE_ABSENT);
CHECK_EQ(feed.get_transfers().size(), 0);
}

TEST_CASE("Calendar")
{
Feed feed("data/sample_feed");
auto res = feed.read_calendar();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);
const auto & calendar = feed.get_calendar();
CHECK_EQ(calendar.size(), 2);
REQUIRE_EQ(calendar.size(), 2);

const auto calendar_record = feed.get_calendar("WE");
CHECK(calendar_record);
REQUIRE(calendar_record);

CHECK_EQ(calendar_record->start_date, Date(2007, 01, 01));
CHECK_EQ(calendar_record->end_date, Date(2010, 12, 31));
Expand All @@ -199,12 +199,12 @@ TEST_CASE("Calendar dates")
{
Feed feed("data/sample_feed");
auto res = feed.read_calendar_dates();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);
const auto & calendar_dates = feed.get_calendar_dates();
CHECK_EQ(calendar_dates.size(), 1);
REQUIRE_EQ(calendar_dates.size(), 1);

const auto calendar_record = feed.get_calendar_dates("FULLW");
CHECK(!calendar_record.empty());
REQUIRE(!calendar_record.empty());

CHECK_EQ(calendar_record[0].date, Date(2007, 06, 04));
CHECK_EQ(calendar_record[0].exception_type, CalendarDateException::Removed);
Expand All @@ -214,7 +214,7 @@ TEST_CASE("Read GTFS feed")
{
Feed feed("data/sample_feed");
auto res = feed.read_feed();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);
CHECK_EQ(feed.get_agencies().size(), 1);
CHECK_EQ(feed.get_routes().size(), 5);
CHECK_EQ(feed.get_trips().size(), 11);
Expand All @@ -227,9 +227,9 @@ TEST_CASE("Agency")
{
Feed feed("data/sample_feed");
auto res = feed.read_agencies();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);
const auto & agencies = feed.get_agencies();
CHECK_EQ(agencies.size(), 1);
REQUIRE_EQ(agencies.size(), 1);
CHECK_EQ(agencies[0].agency_id, "DTA");
CHECK_EQ(agencies[0].agency_name, "Demo Transit Authority");
CHECK_EQ(agencies[0].agency_url, "http://google.com");
Expand All @@ -244,9 +244,9 @@ TEST_CASE("Routes")
{
Feed feed("data/sample_feed");
auto res = feed.read_routes();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);
const auto & routes = feed.get_routes();
CHECK_EQ(routes.size(), 5);
REQUIRE_EQ(routes.size(), 5);
CHECK_EQ(routes[0].route_id, "AB");
CHECK_EQ(routes[0].agency_id, "DTA");
CHECK_EQ(routes[0].route_short_name, "10");
Expand All @@ -264,9 +264,9 @@ TEST_CASE("Trips")
{
Feed feed("data/sample_feed");
auto res = feed.read_trips();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);
const auto & trips = feed.get_trips();
CHECK_EQ(trips.size(), 11);
REQUIRE_EQ(trips.size(), 11);

CHECK_EQ(trips[0].block_id, "1");
CHECK_EQ(trips[0].route_id, "AB");
Expand All @@ -277,18 +277,18 @@ TEST_CASE("Trips")
CHECK_EQ(trips[0].trip_id, "AB1");

auto const trip = feed.get_trip("AB1");
CHECK(trip);
REQUIRE(trip);
CHECK(trip.value().trip_short_name.empty());
}

TEST_CASE("Stops")
{
Feed feed("data/sample_feed");
auto res = feed.read_stops();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);

const auto & stops = feed.get_stops();
CHECK_EQ(stops.size(), 9);
REQUIRE_EQ(stops.size(), 9);
CHECK_EQ(stops[0].stop_lat, 36.425288);
CHECK_EQ(stops[0].stop_lon, -117.133162);
CHECK(stops[0].stop_code.empty());
Expand All @@ -307,10 +307,10 @@ TEST_CASE("StopTimes")
{
Feed feed("data/sample_feed");
auto res = feed.read_stop_times();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);

const auto & stop_times = feed.get_stop_times();
CHECK_EQ(stop_times.size(), 28);
REQUIRE_EQ(stop_times.size(), 28);

CHECK_EQ(stop_times[0].trip_id, "STBA");
CHECK_EQ(stop_times[0].arrival_time, Time(06, 00, 00));
Expand All @@ -329,10 +329,10 @@ TEST_CASE("Shapes")
{
Feed feed("data/sample_feed");
auto res = feed.read_shapes();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);

const auto & shapes = feed.get_shapes();
CHECK_EQ(shapes.size(), 8);
REQUIRE_EQ(shapes.size(), 8);
CHECK_EQ(shapes[0].shape_id, "10237");
CHECK_EQ(shapes[0].shape_pt_lat, 43.5176524709);
CHECK_EQ(shapes[0].shape_pt_lon, -79.6906570431);
Expand All @@ -347,10 +347,10 @@ TEST_CASE("Calendar")
{
Feed feed("data/sample_feed");
auto res = feed.read_calendar();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);

const auto & calendar = feed.get_calendar();
CHECK_EQ(calendar.size(), 2);
REQUIRE_EQ(calendar.size(), 2);
CHECK_EQ(calendar[0].service_id, "FULLW");
CHECK_EQ(calendar[0].start_date, Date(2007, 01, 01));
CHECK_EQ(calendar[0].end_date, Date(2010, 12, 31));
Expand All @@ -365,10 +365,10 @@ TEST_CASE("Calendar dates")
{
Feed feed("data/sample_feed");
auto res = feed.read_calendar_dates();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);

const auto & calendar_dates = feed.get_calendar_dates();
CHECK_EQ(calendar_dates.size(), 1);
REQUIRE_EQ(calendar_dates.size(), 1);
CHECK_EQ(calendar_dates[0].service_id, "FULLW");
CHECK_EQ(calendar_dates[0].date, Date(2007, 06, 04));
CHECK_EQ(calendar_dates[0].exception_type, CalendarDateException::Removed);
Expand All @@ -381,10 +381,10 @@ TEST_CASE("Frequencies")
{
Feed feed("data/sample_feed");
auto res = feed.read_frequencies();
CHECK_EQ(res.code, ResultCode::OK);
REQUIRE_EQ(res.code, ResultCode::OK);

const auto & frequencies = feed.get_frequencies();
CHECK_EQ(frequencies.size(), 11);
REQUIRE_EQ(frequencies.size(), 11);
CHECK_EQ(frequencies[0].trip_id, "STBA");
CHECK_EQ(frequencies[0].start_time, Time(6, 00, 00));
CHECK_EQ(frequencies[0].end_time, Time(22, 00, 00));
Expand Down

0 comments on commit 90a89d7

Please sign in to comment.