From 7d9ee09e3c2eec219a3908cef1606c6a40c453f2 Mon Sep 17 00:00:00 2001 From: axin Date: Thu, 9 May 2013 23:47:39 +0200 Subject: [PATCH] added test cases for day wrap in opening hours --- .../net/osmand/util/OpeningHoursParser.java | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java index eafbebcc05..32ecb2b198 100644 --- a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java +++ b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java @@ -8,7 +8,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; - /** * Class used to parse opening hours * @@ -597,6 +596,41 @@ public class OpeningHoursParser { testOpened("12.08.2012 23:00", hours, true); testOpened("08.08.2012 12:00", hours, false); testOpened("08.08.2012 05:00", hours, true); + + // test simple day wrap + hours = parseOpenedHours("Mo 20:00-02:00"); + System.out.println(hours); + testOpened("05.05.2013 10:30", hours, false); + testOpened("05.05.2013 23:59", hours, false); + testOpened("06.05.2013 10:30", hours, false); + testOpened("06.05.2013 20:30", hours, true); + testOpened("06.05.2013 23:59", hours, true); + testOpened("07.05.2013 00:00", hours, true); + testOpened("07.05.2013 00:30", hours, true); + testOpened("07.05.2013 01:59", hours, true); + testOpened("07.05.2013 20:30", hours, false); + + // test maximum day wrap + hours = parseOpenedHours("Su 10:00-10:00"); + System.out.println(hours); + testOpened("05.05.2013 09:59", hours, false); + testOpened("05.05.2013 10:00", hours, true); + testOpened("05.05.2013 23:59", hours, true); + testOpened("06.05.2013 00:00", hours, true); + testOpened("06.05.2013 09:59", hours, true); + testOpened("06.05.2013 10:00", hours, false); + + // test day wrap as seen on OSM + 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); + testOpened("05.05.2013 05:00", hours, false); + testOpened("05.05.2013 12:30", hours, false); + testOpened("06.05.2013 10:30", hours, false); + testOpened("07.05.2013 01:00", hours, false); + testOpened("07.05.2013 20:25", hours, true); + testOpened("07.05.2013 23:59", hours, true); + testOpened("08.05.2013 00:00", hours, true); + testOpened("08.05.2013 02:00", hours, false); } - }