rdf-ex/test/unit/triple_test.exs
Marcel Otto 5819eec0cf Re-integrate XSD.ex
It turned out that the costs of separating the XSD datatypes are too high
and probably not worth the effort, since with its limited scope
probably nobody would want to use XSD.ex outside of the RDF.ex context
anyway.
2020-05-05 23:58:44 +02:00

29 lines
865 B
Elixir

defmodule RDF.TripleTest do
use RDF.Test.Case
doctest RDF.Triple
alias RDF.Triple
describe "values/1" do
test "with a valid RDF.Triple" do
assert Triple.values({~I<http://example.com/S>, ~I<http://example.com/p>, XSD.integer(42)})
== {"http://example.com/S", "http://example.com/p", 42}
end
test "with an invalid RDF.Triple" do
refute Triple.values({~I<http://example.com/S>, ~I<http://example.com/p>})
refute Triple.values({self(), self(), self()})
end
end
test "values/2" do
assert {~I<http://example.com/S>, ~I<http://example.com/p>, XSD.integer(42)}
|> Triple.values(fn
{:object, object} -> object |> RDF.Term.value() |> Kernel.+(1)
{_, term} -> term |> to_string() |> String.last()
end)
== {"S", "p", 43}
end
end