Add tests for nested quoted triples in N-Triples-star

This commit is contained in:
Marcel Otto 2021-10-05 01:09:29 +02:00
parent 3937e3f60c
commit c3556bf79e
2 changed files with 35 additions and 2 deletions

View file

@ -0,0 +1,18 @@
defmodule RDF.Star.NTriples.DecoderTest do
use RDF.Test.Case
alias RDF.NTriples
test "nested quoted triples" do
assert NTriples.Decoder.decode!("""
<< << <http://example.com/s1> <http://example.com/p1> <http://example.com/o1> >> <http://example.com/q1> << <http://example.com/s2> <http://example.com/p2> <http://example.com/o2> >> >> <http://example.com/q2> << << <http://example.com/s3> <http://example.com/p3> <http://example.com/o3> >> <http://example.com/q3> << <http://example.com/s4> <http://example.com/p4> <http://example.com/o4> >> >> .
""") ==
Graph.new([
{
{{EX.s1(), EX.p1(), EX.o1()}, EX.q1(), {EX.s2(), EX.p2(), EX.o2()}},
EX.q2(),
{{EX.s3(), EX.p3(), EX.o3()}, EX.q3(), {EX.s4(), EX.p4(), EX.o4()}}
}
])
end
end

View file

@ -3,14 +3,14 @@ defmodule RDF.Star.NTriples.EncoderTest do
alias RDF.NTriples alias RDF.NTriples
test "annotations of triples on subject position" do test "quoted triples on subject position" do
assert NTriples.Encoder.encode!(graph_with_annotation()) == assert NTriples.Encoder.encode!(graph_with_annotation()) ==
""" """
<< <http://example.com/S> <http://example.com/P> "Foo" >> <http://example.com/ap> <http://example.com/ao> . << <http://example.com/S> <http://example.com/P> "Foo" >> <http://example.com/ap> <http://example.com/ao> .
""" """
end end
test "annotations of triples on object position" do test "quoted triples on object position" do
assert NTriples.Encoder.encode!( assert NTriples.Encoder.encode!(
Graph.new([ Graph.new([
statement(), statement(),
@ -22,4 +22,19 @@ defmodule RDF.Star.NTriples.EncoderTest do
<http://example.com/S> <http://example.com/P> "Foo" . <http://example.com/S> <http://example.com/P> "Foo" .
""" """
end end
test "nested quoted triples" do
assert NTriples.Encoder.encode!(
Graph.new([
{
{{EX.s1(), EX.p1(), EX.o1()}, EX.q1(), {EX.s2(), EX.p2(), EX.o2()}},
EX.q2(),
{{EX.s3(), EX.p3(), EX.o3()}, EX.q3(), {EX.s4(), EX.p4(), EX.o4()}}
}
])
) ==
"""
<< << <http://example.com/s1> <http://example.com/p1> <http://example.com/o1> >> <http://example.com/q1> << <http://example.com/s2> <http://example.com/p2> <http://example.com/o2> >> >> <http://example.com/q2> << << <http://example.com/s3> <http://example.com/p3> <http://example.com/o3> >> <http://example.com/q3> << <http://example.com/s4> <http://example.com/p4> <http://example.com/o4> >> >> .
"""
end
end end