Skip to content

Commit

Permalink
test: trips where the sequence is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianprelipcean committed Apr 19, 2024
1 parent 9116db0 commit 375a443
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
27 changes: 27 additions & 0 deletions expected/pgtfs_test.out
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@ $$
2 | 1 | 1712759936 | 1753
(2 rows)

-- simple connectivity test where sequence has a gap (3 is missing)
select
stop_id,
stop_sequence,
arrival_time,
trip_id
from pgtfs_csa(
'1', '4', 1712707200.0,
$$
select trip_id, stop_id, arrival_time::double precision, departure_time::double precision, stop_sequence::int from (
values
('1753','1',NULL,1712757660,1),
('1753','2',1712759880,1712759940,2),
('1753','3',1712762040,1712762100,4),
('1753','4',1712762100,NULL,5)
)
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence);
$$
);
stop_id | stop_sequence | arrival_time | trip_id
---------+---------------+--------------+---------
1 | 0 | 1712707200 |
2 | 1 | 1712759936 | 1753
3 | 2 | 1712761984 | 1753
4 | 3 | 1712762112 | 1753
(4 rows)

-- connected and route on single trip
select
stop_id,
Expand Down
20 changes: 20 additions & 0 deletions sql/pgtfs_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ select trip_id, stop_id, arrival_time::double precision, departure_time::double
$$
);

-- simple connectivity test where sequence has a gap (3 is missing)
select
stop_id,
stop_sequence,
arrival_time,
trip_id
from pgtfs_csa(
'1', '4', 1712707200.0,
$$
select trip_id, stop_id, arrival_time::double precision, departure_time::double precision, stop_sequence::int from (
values
('1753','1',NULL,1712757660,1),
('1753','2',1712759880,1712759940,2),
('1753','3',1712762040,1712762100,4),
('1753','4',1712762100,NULL,5)
)
as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence);
$$
);

-- connected and route on single trip
select
stop_id,
Expand Down

0 comments on commit 375a443

Please sign in to comment.