Test for fare attribetes read & write.

This commit is contained in:
Khlopkova Olga 2021-02-01 14:37:02 +03:00
parent d93723861e
commit 5a6590533c
2 changed files with 14 additions and 0 deletions
include/just_gtfs
tests

View file

@ -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
{

View file

@ -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")