Add RDF.Diff.empty?/1
This commit is contained in:
parent
a1cbbd24b6
commit
a77fe7c56e
2 changed files with 17 additions and 0 deletions
|
@ -150,6 +150,15 @@ defmodule RDF.Diff do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Determines if a diff is empty.
|
||||||
|
|
||||||
|
A `RDF.Diff` is empty, if its `additions` and `deletions` graphs are empty.
|
||||||
|
"""
|
||||||
|
def empty?(%__MODULE__{} = diff) do
|
||||||
|
Enum.empty?(diff.additions) and Enum.empty?(diff.deletions)
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Applies a diff to a `RDF.Graph` or `RDF.Description` by deleting the `deletions` and adding the `additions` of the `diff`.
|
Applies a diff to a `RDF.Graph` or `RDF.Description` by deleting the `deletions` and adding the `additions` of the `diff`.
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,14 @@ defmodule RDF.DiffTest do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "empty?/1" do
|
||||||
|
assert Diff.empty?(Diff.new()) == true
|
||||||
|
assert Diff.empty?(Diff.new(additions: EX.p(EX.S, EX.O),
|
||||||
|
deletions: EX.p(EX.S, EX.O))) == false
|
||||||
|
assert Diff.empty?(Diff.new(additions: EX.p(EX.S, EX.O))) == false
|
||||||
|
assert Diff.empty?(Diff.new(deletions: EX.p(EX.S, EX.O))) == false
|
||||||
|
end
|
||||||
|
|
||||||
describe "apply/2" do
|
describe "apply/2" do
|
||||||
test "on a graph" do
|
test "on a graph" do
|
||||||
assert Diff.new(
|
assert Diff.new(
|
||||||
|
|
Loading…
Reference in a new issue