diff --git a/include/just_gtfs/just_gtfs.h b/include/just_gtfs/just_gtfs.h index 9fbb789..def363f 100644 --- a/include/just_gtfs/just_gtfs.h +++ b/include/just_gtfs/just_gtfs.h @@ -999,6 +999,15 @@ struct FareAttributesItem size_t transfer_duration = 0; // Length of time in seconds before a transfer expires }; + +inline bool operator==(const FareAttributesItem & lhs, const FareAttributesItem & rhs) +{ + return std::tie(lhs.fare_id, lhs.price, lhs.currency_type, lhs.payment_method, + lhs.transfers, lhs.agency_id, lhs.transfer_duration) == + std::tie(rhs.fare_id, rhs.price, rhs.currency_type, rhs.payment_method, + rhs.transfers, rhs.agency_id, rhs.transfer_duration); +} + // Optional dataset file struct FareRule { diff --git a/tests/unit_tests.cpp b/tests/unit_tests.cpp index 5eafc31..8e738b5 100644 --- a/tests/unit_tests.cpp +++ b/tests/unit_tests.cpp @@ -519,6 +519,11 @@ TEST_CASE("Fare attributes") const auto & attributes_for_id = feed.get_fare_attributes("a"); REQUIRE_EQ(attributes_for_id.size(), 1); CHECK_EQ(attributes_for_id[0].price, 5.25); + + REQUIRE_EQ(feed.write_fare_attributes("data/output_feed"), ResultCode::OK); + Feed feed_copy("data/output_feed"); + REQUIRE_EQ(feed_copy.read_fare_attributes(), ResultCode::OK); + CHECK_EQ(attributes, feed_copy.get_fare_attributes()); } TEST_CASE("Fare rules")