aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2020-12-17 18:06:00 +0000
committerFederico Igne <federico.igne@cs.ox.ac.uk>2020-12-17 18:06:18 +0000
commite1e5774575ffa29a3b0414379a1194d72c9c17d6 (patch)
treeb138a5495ae9ac350f491ff37b5664cef9381922
parent77746f19f9298975470e75de8e9071e7f317bda5 (diff)
downloadRSAComb-e1e5774575ffa29a3b0414379a1194d72c9c17d6.tar.gz
RSAComb-e1e5774575ffa29a3b0414379a1194d72c9c17d6.zip
Fix and improve tests for CQ answer class
-rw-r--r--src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswerSpecs.scala53
1 files changed, 48 insertions, 5 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 b2319bc..6e7d6df 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
@@ -16,25 +16,25 @@ object ConjunctiveQueryAnswerSpec {
16 val oneAnswer = new ConjunctiveQueryAnswers( 16 val oneAnswer = new ConjunctiveQueryAnswers(
17 false, 17 false,
18 Seq(varX, varY, varZ), 18 Seq(varX, varY, varZ),
19 Seq(Seq(iri1, iri2, iri3)) 19 Seq((4, Seq(iri1, iri2, iri3)))
20 ) 20 )
21 val multipleAnswers = 21 val multipleAnswers =
22 new ConjunctiveQueryAnswers( 22 new ConjunctiveQueryAnswers(
23 false, 23 false,
24 Seq(varY, varZ), 24 Seq(varY, varZ),
25 Seq(Seq(iri1, iri1), Seq(iri1, iri2), Seq(iri1, iri3)) 25 Seq((1, Seq(iri1, iri1)), (2, Seq(iri1, iri2)), (1, Seq(iri1, iri3)))
26 ) 26 )
27 val noAnswer = new ConjunctiveQueryAnswers(false, Seq(), Seq()) 27 val noAnswer = new ConjunctiveQueryAnswers(false, Seq(), Seq())
28 val emptyAnswer = 28 val emptyAnswer =
29 new ConjunctiveQueryAnswers(false, Seq(varX, varY), Seq(Seq())) 29 new ConjunctiveQueryAnswers(false, Seq(varX, varY), Seq((3, Seq())))
30 30
31 val falseAnswer = new ConjunctiveQueryAnswers(true, Seq(), Seq()) 31 val falseAnswer = new ConjunctiveQueryAnswers(true, Seq(), Seq())
32 val trueAnswer1 = new ConjunctiveQueryAnswers(true, Seq(), Seq(Seq())) 32 val trueAnswer1 = new ConjunctiveQueryAnswers(true, Seq(), Seq((1, Seq())))
33 val trueAnswer2 = 33 val trueAnswer2 =
34 new ConjunctiveQueryAnswers( 34 new ConjunctiveQueryAnswers(
35 true, 35 true,
36 Seq(varX, varY), 36 Seq(varX, varY),
37 Seq(Seq(iri1, iri1), Seq(iri1, iri2), Seq(iri1, iri3)) 37 Seq((5, Seq(iri1, iri1)), (2, Seq(iri1, iri2)), (1, Seq(iri1, iri3)))
38 ) 38 )
39} 39}
40 40
@@ -42,6 +42,49 @@ class ConjunctiveQueryAnswerSpec extends AnyFlatSpec with Matchers {
42 42
43 import ConjunctiveQueryAnswerSpec._ 43 import ConjunctiveQueryAnswerSpec._
44 44
45 "Test answer 1" should "have length 1 (4 with multiplicity)" in {
46 oneAnswer should have(
47 'length (1),
48 'lengthWithMultiplicity (4)
49 )
50 }
51 "Test answer 2" should "have length 3 (4 with multiplicity)" in {
52 multipleAnswers should have(
53 'length (3),
54 'lengthWithMultiplicity (4)
55 )
56 }
57 "Test answer 3" should "have length 0 (0 with multiplicity)" in {
58 noAnswer should have(
59 'length (0),
60 'lengthWithMultiplicity (0)
61 )
62 }
63 "Test answer 4" should "have length 1 (3 with multiplicity)" in {
64 noAnswer should have(
65 'length (1),
66 'lengthWithMultiplicity (3)
67 )
68 }
69 "Test boolean answer 1" should "have length 0 (0 with multiplicity)" in {
70 falseAnswer should have(
71 'length (0),
72 'lengthWithMultiplicity (0)
73 )
74 }
75 "Test boolean answer 2" should "have length 1 (1 with multiplicity)" in {
76 trueAnswer1 should have(
77 'length (1),
78 'lengthWithMultiplicity (1)
79 )
80 }
81 "Test boolean answer 3" should "have length 3 (8 with multiplicity)" in {
82 trueAnswer2 should have(
83 'length (3),
84 'lengthWithMultiplicity (8)
85 )
86 }
87
45 "A conjunctive query" should "print an header and a single line if it has a single answer" in { 88 "A conjunctive query" should "print an header and a single line if it has a single answer" in {
46 oneAnswer.toString shouldBe s"X\tY\tZ\n${iri1.getIRI}\t${iri2.getIRI}\t${iri3.getIRI}" 89 oneAnswer.toString shouldBe s"X\tY\tZ\n${iri1.getIRI}\t${iri2.getIRI}\t${iri3.getIRI}"
47 } 90 }