Skip to content

Commit

Permalink
Fix for shapes.txt header with test
Browse files Browse the repository at this point in the history
  • Loading branch information
mesozoic-drones committed Mar 1, 2023
1 parent 574b946 commit 2449d00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/just_gtfs/just_gtfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ inline void write_routes_header(std::ofstream & out)
inline void write_shapes_header(std::ofstream & out)
{
std::vector<std::string> fields = {"shape_id", "shape_pt_lat", "shape_pt_lon",
"shape_pt_sequence"};
"shape_pt_sequence", "shape_dist_traveled"};
write_joined(out, std::move(fields));
}

Expand Down
4 changes: 4 additions & 0 deletions tests/data/output_feed/shapes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence,shape_dist_traveled
id1,61.197843,-149.867731,0,0.0
id1,61.199419,-149.867680,1,178.0
id2,61.199972,-149.867731,2,416.0
14 changes: 14 additions & 0 deletions tests/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,18 @@ TEST_CASE("Agencies create & save")
REQUIRE_EQ(feed_for_testing.read_agencies(), ResultCode::OK);
CHECK_EQ(feed_for_writing.get_agencies(), feed_for_testing.get_agencies());
}

TEST_CASE("Shapes create & save")
{
Feed feed_for_writing;

feed_for_writing.add_shape(ShapePoint{"id1", 61.197843, -149.867731, 0, 0});
feed_for_writing.add_shape(ShapePoint{"id1", 61.199419, -149.867680, 1, 178});
feed_for_writing.add_shape(ShapePoint{"id2", 61.199972, -149.867731, 2, 416});

REQUIRE_EQ(feed_for_writing.write_shapes("data/output_feed"), ResultCode::OK);
Feed feed_for_testing("data/output_feed");

REQUIRE_EQ(feed_for_testing.read_shapes(), ResultCode::OK);
}
TEST_SUITE_END();

0 comments on commit 2449d00

Please sign in to comment.