|
| 1 | +/* :file: This file is part of the pgRouting project. |
| 2 | +:copyright: Copyright (c) 2016-2026 pgRouting developers |
| 3 | +:license: Creative Commons Attribution-Share Alike 3.0 https://creativecommons.org/licenses/by-sa/3.0 */ |
| 4 | + |
| 5 | +BEGIN; |
| 6 | +SET client_min_messages TO WARNING; |
| 7 | + |
| 8 | +SELECT CASE WHEN min_version('4.0.1') THEN plan(8) ELSE plan(1) END; |
| 9 | + |
| 10 | + |
| 11 | +CREATE OR REPLACE FUNCTION test_function() |
| 12 | +RETURNS SETOF TEXT AS |
| 13 | +$BODY$ |
| 14 | +BEGIN |
| 15 | + IF NOT min_version('4.0.1') THEN |
| 16 | + RETURN query |
| 17 | + SELECT skip(1, 'bad alloc error Fixed on 4.0.1'); |
| 18 | + RETURN; |
| 19 | + END IF; |
| 20 | + |
| 21 | + PREPARE edges AS |
| 22 | + SELECT * |
| 23 | + FROM ( |
| 24 | + VALUES |
| 25 | + (100, 1, 2, 1, 1), |
| 26 | + (101, 2, 3, 1, 1), |
| 27 | + (102, 3, 4, 1, 1) |
| 28 | + ) AS edge_table(id, source, target, cost, reverse_cost); |
| 29 | + |
| 30 | + PREPARE points AS |
| 31 | + SELECT * |
| 32 | + FROM ( |
| 33 | + VALUES (1, 101, 0.5::FLOAT) |
| 34 | + ) AS t(pid, edge_id, fraction); |
| 35 | + |
| 36 | + RETURN QUERY |
| 37 | + SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 4], 'r')$$, |
| 38 | + 'withPointsVia lives when all via vertices exist in the graph'); |
| 39 | + RETURN QUERY |
| 40 | + SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 4], 'r')$$, |
| 41 | + 'withPointsVia returns results when all via vertices exist in the graph'); |
| 42 | + |
| 43 | + RETURN QUERY |
| 44 | + SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 5], 'r')$$, |
| 45 | + 'withPointsVia lives when a via vertex does not exist in the graph'); |
| 46 | + RETURN QUERY |
| 47 | + SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 3, 5], 'r')$$, |
| 48 | + 'withPointsVia returns results when a via vertex does not exist in the graph'); |
| 49 | + |
| 50 | + RETURN QUERY |
| 51 | + SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 5, 4], 'r')$$, |
| 52 | + 'withPointsVia handles via vertex missing between two valid vertices'); |
| 53 | + RETURN QUERY |
| 54 | + SELECT is_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, 5, 4], 'r');$$, |
| 55 | + 'withPointsVia returns empty when via vertex missing between two valid vertices'); |
| 56 | + |
| 57 | + RETURN QUERY |
| 58 | + SELECT lives_ok($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, -1, 4], 'r')$$, |
| 59 | + 'withPointsVia lives when via includes a point pid that exists'); |
| 60 | + RETURN QUERY |
| 61 | + SELECT isnt_empty($$SELECT * FROM pgr_withPointsVia('edges', 'points', ARRAY[1, -1, 4], 'r')$$, |
| 62 | + 'withPointsVia returns results when via includes a point pid that exists'); |
| 63 | +END |
| 64 | +$BODY$ |
| 65 | +language plpgsql; |
| 66 | + |
| 67 | +SELECT test_function(); |
| 68 | + |
| 69 | +SELECT * FROM finish(); |
| 70 | +ROLLBACK; |
0 commit comments