Skip to content

Instantly share code, notes, and snippets.

@jchapuis
Created March 22, 2021 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchapuis/5f39159f1f31e6f82c8e6ac440a9f678 to your computer and use it in GitHub Desktop.
Save jchapuis/5f39159f1f31e6f82c8e6ac440a9f678 to your computer and use it in GitHub Desktop.
Parsable diagrams
"DateTimeInterval.relate" should {
"return Disjoint" in new Fixture {
val a = "+---+ "
val b = " +--+"
a.relateTo(b) shouldBe Disjoint
b.relateTo(a) shouldBe Disjoint
}
"return IncludedBy and Includes" in new Fixture {
val a = " +-------+ "
val b = " +--+ "
a.relateTo(b) shouldBe Includes
b.relateTo(a) shouldBe IncludedBy
}
"return IncludesFlushRight and IncludedByFlushRight when flush right" in new Fixture {
val a = " +---------+ "
val b = " +-----+ "
a.relateTo(b) shouldBe IncludesFlushRight
b.relateTo(a) shouldBe IncludedByFlushRight
}
"return IncludesFlushLeft and IncludedByFlushLeft when flush left" in new Fixture {
val a = " +---------+ "
val b = " +-----+ "
a.relateTo(b) shouldBe IncludesFlushLeft
b.relateTo(a) shouldBe IncludedByFlushLeft
}
"return Overlaps left and right" in new Fixture {
val a = " +------+ "
val b = " +-----+ "
a.relateTo(b) shouldBe OverlapsLeft
b.relateTo(a) shouldBe OverlapsRight
val c = " +------+ "
val d = " +---+ "
c.relateTo(d) shouldBe OverlapsRight
d.relateTo(c) shouldBe OverlapsLeft
val f = " +----+ "
val e = " +-+ "
f.relateTo(e) shouldBe OverlapsRight
e.relateTo(f) shouldBe OverlapsLeft
}
"return Equals" in new Fixture {
val a = " +---------+ "
val b = " +---------+ "
a.relateTo(b) shouldBe Equals
b.relateTo(a) shouldBe Equals
val c = " ++ "
val d = " ++ "
c.relateTo(d) shouldBe Equals
d.relateTo(c) shouldBe Equals
}
"return AbutsLeft and AbutsRight" in new Fixture {
val a = " +----+ "
val b = " +-----+ "
a.relateTo(b) shouldBe AbutsLeft
b.relateTo(a) shouldBe AbutsRight
val c = " +----+ "
val d = " +-----+ "
c.relateTo(d) shouldBe AbutsRight
d.relateTo(c) shouldBe AbutsLeft
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment