diff --git a/test/unit/ntriples_star_decoder_test.exs b/test/unit/ntriples_star_decoder_test.exs new file mode 100644 index 0000000..0db912b --- /dev/null +++ b/test/unit/ntriples_star_decoder_test.exs @@ -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!(""" + << << >> << >> >> << << >> << >> >> . + """) == + 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 diff --git a/test/unit/ntriples_star_encoder_test.exs b/test/unit/ntriples_star_encoder_test.exs index 004a636..8737bf8 100644 --- a/test/unit/ntriples_star_encoder_test.exs +++ b/test/unit/ntriples_star_encoder_test.exs @@ -3,14 +3,14 @@ defmodule RDF.Star.NTriples.EncoderTest do 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()) == """ << "Foo" >> . """ end - test "annotations of triples on object position" do + test "quoted triples on object position" do assert NTriples.Encoder.encode!( Graph.new([ statement(), @@ -22,4 +22,19 @@ defmodule RDF.Star.NTriples.EncoderTest do "Foo" . """ 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()}} + } + ]) + ) == + """ + << << >> << >> >> << << >> << >> >> . + """ + end end