Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/just_gtfs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhlopkova Olga <o.khlopkova@corp.mail.ru>2021-02-01 14:37:02 +0300
committerKhlopkova Olga <o.khlopkova@corp.mail.ru>2021-02-01 14:37:02 +0300
commit5a6590533cd82dacc5338d8bcb8ecc8fb8ca251c (patch)
tree329624b7c578d8875a23b4311414db4bf4eb47e9
parentd93723861e2347b3f8bdd4d7e3172d259bce6bf7 (diff)
Test for fare attribetes read & write.
-rw-r--r--include/just_gtfs/just_gtfs.h9
-rw-r--r--tests/unit_tests.cpp5
2 files changed, 14 insertions, 0 deletions
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")