Skip to content

Commit

Permalink
Merge pull request mesozoic-drones#1 from mesozoic-drones/fix-for-sha…
Browse files Browse the repository at this point in the history
…pe-writing

Fix for shapes.txt header with test
  • Loading branch information
mesozoic-drones authored Mar 1, 2023
2 parents 574b946 + 859c134 commit b2b96ad
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: C/C++ CI

on:
push:
branches: [ master, add-* ]
branches: [ master, add-*, fix-* ]
pull_request:
branches: [ master ]

Expand Down
2 changes: 1 addition & 1 deletion doctest
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
15 changes: 15 additions & 0 deletions tests/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,19 @@ 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);
CHECK_EQ(feed_for_testing.get_shapes().size(), 3);
}
TEST_SUITE_END();

0 comments on commit b2b96ad

Please sign in to comment.