aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-05-24 22:28:13 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-05-24 22:28:13 +0200
commitac374b555accaf7a83424c241f38f997dc6a2068 (patch)
treed598692548f1daf186623bed8db62b7f77312673 /tests
parentMinor change. (diff)
downloadcalp-ac374b555accaf7a83424c241f38f997dc6a2068.tar.gz
calp-ac374b555accaf7a83424c241f38f997dc6a2068.tar.xz
Timespan-overlaps? single moment and tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/datetime-util.scm64
1 files changed, 62 insertions, 2 deletions
diff --git a/tests/datetime-util.scm b/tests/datetime-util.scm
index 4ba432ca..80a8df5e 100644
--- a/tests/datetime-util.scm
+++ b/tests/datetime-util.scm
@@ -1,5 +1,5 @@
-(((datetime) date time)
- ((datetime util) month-stream in-date-range?)
+(((datetime) date time datetime)
+ ((datetime util) month-stream in-date-range? timespan-overlaps?)
((srfi srfi-41) stream->list stream-take
))
@@ -24,3 +24,63 @@
(not ((in-date-range? #2020-01-01 #2020-02-29)
#2018-02-02)))
+
+
+
+(test-assert "A"
+ (timespan-overlaps? #2020-01-01 #2020-01-10
+ #2020-01-05 #2020-01-15))
+
+(test-assert "A, shared start"
+ (timespan-overlaps? #2020-01-01 #2020-01-10
+ #2020-01-01 #2020-01-15))
+
+(test-assert "A, tangential"
+ (not (timespan-overlaps? #2020-01-01T00:00:00 #2020-01-10T00:00:00
+ #2020-01-10T00:00:00 #2020-01-30T00:00:00)))
+
+
+
+(test-assert "s1 instant"
+ (timespan-overlaps? #2020-01-15T10:00:00 #2020-01-15T10:00:00
+ #2020-01-10T00:00:00 #2020-01-30T00:00:00))
+
+(test-assert "s2 instant"
+ (timespan-overlaps? #2020-01-10T00:00:00 #2020-01-30T00:00:00
+ #2020-01-15T10:00:00 #2020-01-15T10:00:00))
+
+(test-assert "s1 instant, shared start with s2"
+ (timespan-overlaps? #2020-01-15T10:00:00 #2020-01-15T10:00:00
+ #2020-01-15T10:00:00 #2020-01-30T00:00:00))
+
+
+(test-assert "s1 instant, shared end with s2"
+ (not (timespan-overlaps? #2020-01-15T10:00:00 #2020-01-15T10:00:00
+ #2020-01-10T00:00:00 #2020-01-15T10:00:00)))
+
+(test-assert "s2 instant, shared start with s1"
+ (timespan-overlaps? #2020-01-15T10:00:00 #2020-01-30T00:00:00
+ #2020-01-15T10:00:00 #2020-01-15T10:00:00))
+
+
+(test-assert "s2 instant, shared end with s1"
+ (not (timespan-overlaps? #2020-01-10T00:00:00 #2020-01-15T10:00:00
+ #2020-01-15T10:00:00 #2020-01-15T10:00:00)))
+
+
+(test-assert "both instant"
+ (not (timespan-overlaps? #2020-01-15T10:00:00 #2020-01-15T10:00:00
+ #2020-01-15T10:00:00 #2020-01-15T10:00:00)))
+
+(test-assert "tangential whole day"
+ (not (timespan-overlaps? #2020-01-01 #2020-01-02
+ #2020-01-02 #2020-01-03)))
+
+(test-assert "B"
+ (timespan-overlaps? #2020-01-05 #2020-01-15
+ #2020-01-01 #2020-01-10))
+
+
+(test-assert "E"
+ (timespan-overlaps? #2020-01-01 #2020-01-10
+ #2020-01-01 #2020-01-10))