Skip to content

Commit 7b2154a

Browse files
committed
Update tests
1 parent cf1908d commit 7b2154a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/jsonpatch/path_util.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,8 @@ defmodule Jsonpatch.PathUtil do
205205
end
206206
end
207207

208-
defp is_number?(term) when is_binary(term) do
209-
Regex.match?(~r/^\d+$/, term)
210-
end
211-
212-
defp is_number?(_term) do
213-
false
208+
defp is_number?(term) do
209+
is_binary(term) and Regex.match?(~r/^\d+$/, term)
214210
end
215211

216212
defp do_unescape(fragment, pattern, replacement) when is_binary(fragment) do

test/jsonpatch_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ defmodule JsonpatchTest do
5050
assert [%Remove{path: "/baz"}] = patch
5151
end
5252

53+
test "Create no diff on unexpected input" do
54+
assert [] = Jsonpatch.diff("unexpected", 1)
55+
end
56+
5357
test "A.4. Removing an Array Element" do
5458
source = %{"a" => %{"b" => ["c", "d"]}}
5559
destination = %{"a" => %{"b" => ["c"]}}

0 commit comments

Comments
 (0)