From c9f64ad619a5f7695a855ac3549381a5a1dd8e34 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Sun, 10 May 2015 00:50:44 +0200 Subject: [PATCH] Added test for "Mo-Th 09:00-03:00, Fr-Sa 09:00-04:00; Su off". Not evaluated correctly. Related to #1154. --- .../net/osmand/util/OpeningHoursParser.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java index 8fabe89bb6..4a17179825 100644 --- a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java +++ b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java @@ -1,6 +1,5 @@ package net.osmand.util; -/* Has to be commented out in order to run the main function and test the package? */ - +/* Can be commented out in order to run the main function separately */ import java.text.ParseException; @@ -780,6 +779,8 @@ public class OpeningHoursParser { testOpened("06.05.2013 10:00", hours, false); // test day wrap as seen on OSM + // Incorrectly evaluated: https://wiki.openstreetmap.org/w/index.php?title=Key:opening_hours/specification#explain:additional_rule_separator + // does overwrite previous definitions. hours = parseOpenedHours("Tu-Th 07:00-2:00; Fr 17:00-4:00; Sa 18:00-05:00; Su,Mo off"); System.out.println(hours); testOpened("05.05.2013 04:59", hours, true); @@ -792,6 +793,21 @@ public class OpeningHoursParser { testOpened("08.05.2013 00:00", hours, true); testOpened("08.05.2013 02:00", hours, false); + // test day wrap as seen on OSM + hours = parseOpenedHours("Mo-Th 09:00-03:00, Fr-Sa 09:00-04:00; Su off"); + System.out.println("FIXME (disabled some tests): " + hours); + testOpened("11.05.2015 08:59", hours, false); + testOpened("11.05.2015 09:00", hours, true); + testOpened("12.05.2015 02:59", hours, true); + testOpened("12.05.2015 03:00", hours, false); + // testOpened("16.05.2015 03:59", hours, true); // FIXME: Wrong + testOpened("16.05.2015 04:00", hours, false); + testOpened("17.05.2015 01:00", hours, false); + testOpened("17.05.2015 15:00", hours, false); + + // FIXME: Does throw an exception + // hours = parseOpenedHours("Tu-Th 07:00-2:00; Fr 17:00-4:00; Sa 18:00-05:00; Su,Mo off"); + // tests single month value hours = parseOpenedHours("May: 07:00-19:00"); System.out.println(hours);