diff options
author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-06 16:37:19 +0000 |
---|---|---|
committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-12-06 16:37:19 +0000 |
commit | 920a42b4b55666c582e1d1420336996f4af324fc (patch) | |
tree | cccef2b490dc664d7ce7c520087136142ba1089f /src/test/scala | |
parent | 06e95ce0c738cd54bab7726dfe59e05c814d0e5c (diff) | |
download | RSAComb-920a42b4b55666c582e1d1420336996f4af324fc.tar.gz RSAComb-920a42b4b55666c582e1d1420336996f4af324fc.zip |
Change answer pritty printer to use CSV-like syntax
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala index 65c3e29..ddc6377 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala | |||
@@ -2,28 +2,38 @@ package uk.ac.ox.cs.rsacomb.sparql | |||
2 | 2 | ||
3 | import org.scalatest.flatspec.AnyFlatSpec | 3 | import org.scalatest.flatspec.AnyFlatSpec |
4 | import org.scalatest.matchers.should.Matchers | 4 | import org.scalatest.matchers.should.Matchers |
5 | import tech.oxfordsemantic.jrdfox.logic.expression.IRI | 5 | import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Variable} |
6 | 6 | ||
7 | object ConjunctiveQueryAnswerSpec { | 7 | object ConjunctiveQueryAnswerSpec { |
8 | 8 | ||
9 | val varX = Variable.create("X") | ||
10 | val varY = Variable.create("Y") | ||
11 | val varZ = Variable.create("Z") | ||
9 | val iri1 = IRI.create("_:iri1") | 12 | val iri1 = IRI.create("_:iri1") |
10 | val iri2 = IRI.create("_:iri2") | 13 | val iri2 = IRI.create("_:iri2") |
11 | val iri3 = IRI.create("_:iri3") | 14 | val iri3 = IRI.create("_:iri3") |
12 | 15 | ||
13 | val oneAnswer = new ConjunctiveQueryAnswers(false, Seq(Seq(iri1, iri2, iri3))) | 16 | val oneAnswer = new ConjunctiveQueryAnswers( |
17 | false, | ||
18 | Seq(varX, varY, varZ), | ||
19 | Seq(Seq(iri1, iri2, iri3)) | ||
20 | ) | ||
14 | val multipleAnswers = | 21 | val multipleAnswers = |
15 | new ConjunctiveQueryAnswers( | 22 | new ConjunctiveQueryAnswers( |
16 | false, | 23 | false, |
24 | Seq(varY, varZ), | ||
17 | Seq(Seq(iri1, iri1), Seq(iri1, iri2), Seq(iri1, iri3)) | 25 | Seq(Seq(iri1, iri1), Seq(iri1, iri2), Seq(iri1, iri3)) |
18 | ) | 26 | ) |
19 | val noAnswer = new ConjunctiveQueryAnswers(false, Seq()) | 27 | val noAnswer = new ConjunctiveQueryAnswers(false, Seq(), Seq()) |
20 | val emptyAnswer = new ConjunctiveQueryAnswers(false, Seq(Seq())) | 28 | val emptyAnswer = |
29 | new ConjunctiveQueryAnswers(false, Seq(varX, varY), Seq(Seq())) | ||
21 | 30 | ||
22 | val falseAnswer = new ConjunctiveQueryAnswers(true, Seq()) | 31 | val falseAnswer = new ConjunctiveQueryAnswers(true, Seq(), Seq()) |
23 | val trueAnswer1 = new ConjunctiveQueryAnswers(true, Seq(Seq())) | 32 | val trueAnswer1 = new ConjunctiveQueryAnswers(true, Seq(), Seq(Seq())) |
24 | val trueAnswer2 = | 33 | val trueAnswer2 = |
25 | new ConjunctiveQueryAnswers( | 34 | new ConjunctiveQueryAnswers( |
26 | true, | 35 | true, |
36 | Seq(varX, varY), | ||
27 | Seq(Seq(iri1, iri1), Seq(iri1, iri2), Seq(iri1, iri3)) | 37 | Seq(Seq(iri1, iri1), Seq(iri1, iri2), Seq(iri1, iri3)) |
28 | ) | 38 | ) |
29 | } | 39 | } |
@@ -32,20 +42,20 @@ class ConjunctiveQueryAnswerSpec extends AnyFlatSpec with Matchers { | |||
32 | 42 | ||
33 | import ConjunctiveQueryAnswerSpec._ | 43 | import ConjunctiveQueryAnswerSpec._ |
34 | 44 | ||
35 | "A conjunctive query" should "print a single line if it has a single answer" in { | 45 | "A conjunctive query" should "print an header and a single line if it has a single answer" in { |
36 | oneAnswer.toString shouldBe s"($iri1, $iri2, $iri3)" | 46 | oneAnswer.toString shouldBe s"X\tY\tZ\n$iri1\t$iri2\t$iri3" |
37 | } | 47 | } |
38 | 48 | ||
39 | it should "print multiple answers on multiple lines" in { | 49 | it should "print a header and multiple answers on multiple lines" in { |
40 | multipleAnswers.toString shouldBe s"($iri1, $iri1)\n($iri1, $iri2)\n($iri1, $iri3)" | 50 | multipleAnswers.toString shouldBe s"Y\tZ\n$iri1\t$iri1\n$iri1\t$iri2\n$iri1\t$iri3" |
41 | } | 51 | } |
42 | 52 | ||
43 | it should "print a special \"NO ANSWER\" string when it has no answer" in { | 53 | it should "print a special \"NO ANSWER.\" string when it has no answer" in { |
44 | noAnswer.toString shouldBe "NO ANSWER" | 54 | noAnswer.toString shouldBe "NO ANSWER." |
45 | } | 55 | } |
46 | 56 | ||
47 | it should "print an empty list when it has an empty answer" in { | 57 | it should "print only the header when it has an empty answer" in { |
48 | emptyAnswer.toString shouldBe "()" | 58 | emptyAnswer.toString shouldBe "X\tY\n" |
49 | } | 59 | } |
50 | 60 | ||
51 | "A boolean conjunctive query" should "print \"FALSE\" when it has no answer" in { | 61 | "A boolean conjunctive query" should "print \"FALSE\" when it has no answer" in { |