Skip to content

Commit

Permalink
fix DST sensitive transit test (valhalla#4364)
Browse files Browse the repository at this point in the history
* fix DST sensitive transit test

* fix tidy
  • Loading branch information
nilsnolde authored Oct 28, 2023
1 parent 5b3cd97 commit 08308fe
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions test/gurka/test_gtfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -928,15 +928,27 @@ TEST(GtfsExample, route_trip1) {
EXPECT_FALSE(ti_json["transit_stops"][0].HasMember("arrival_date_time"));
EXPECT_FALSE(ti_json["transit_stops"][2].HasMember("departure_date_time"));

// determine the right day
req_time.append("-04:00"); // TODO: why -04:00, not -05:00??
req_time.replace(req_time.find('T') + 1, 5, "07:00");
EXPECT_EQ(transit_info.transit_stops(0).departure_date_time(), req_time);
EXPECT_EQ(ti_json["transit_stops"][0]["departure_date_time"].GetString(), req_time);

req_time.replace(req_time.find('T') + 1, 5, "07:06");
EXPECT_EQ(transit_info.transit_stops(2).arrival_date_time(), req_time);
EXPECT_EQ(ti_json["transit_stops"][2]["arrival_date_time"].GetString(), req_time);
// determine the right departure datetimes, keep the timezone "+"
req_time.replace(req_time.find('T') + 1, 5, "07:00-");

auto dep_time = transit_info.transit_stops(0).departure_date_time();
dep_time.erase(dep_time.rfind('-') + 1);
std::string dep_time_json = ti_json["transit_stops"][0]["departure_date_time"].GetString();
dep_time_json.erase(dep_time_json.rfind('-') + 1);

EXPECT_EQ(dep_time, req_time);
EXPECT_EQ(dep_time_json, req_time);

// determine the right arrival datetimes, keep the timezone "+"
req_time.replace(req_time.find('T') + 1, 6, "07:06-");

auto arr_time = transit_info.transit_stops(2).arrival_date_time();
arr_time.erase(arr_time.rfind('-') + 1);
std::string arr_time_json = ti_json["transit_stops"][2]["arrival_date_time"].GetString();
arr_time_json.erase(arr_time_json.rfind('-') + 1);

EXPECT_EQ(arr_time_json, req_time);
EXPECT_EQ(arr_time, req_time);
}

TEST(GtfsExample, route_trip4) {
Expand Down

0 comments on commit 08308fe

Please sign in to comment.