aboutsummaryrefslogtreecommitdiff
path: root/slice/slice_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'slice/slice_test.go')
-rw-r--r--slice/slice_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/slice/slice_test.go b/slice/slice_test.go
index 0cf1c40..d678fc7 100644
--- a/slice/slice_test.go
+++ b/slice/slice_test.go
@@ -29,3 +29,22 @@ func TestEmptyPatch(t *testing.T) {
actual := Patch(source, patch)
testutils.AssertSame(t, target, actual, "Target obtained from patch application")
}
+
+type i struct {
+ int
+}
+
+func TestStruct(t *testing.T) {
+ c1, c2, c3, c4, c5, c6, c7, c8 := &i{1}, &i{2}, &i{3}, &i{4}, &i{5}, &i{6}, &i{7}, &i{8}
+ source := Slice{c1, c2, c3, c4}
+ target := Slice{&i{5}, c2, c5, c6, &i{4}, c7, &i{8}}
+ patch := Diff(source, target)
+ testutils.AssertSame(t, []Del{0, 2}, patch.Del, "Patch del part")
+ testutils.AssertSame(t, []Ins{
+ {0, Slice{c5}},
+ {2, Slice{c5, c6}},
+ {5, Slice{c7, c8}},
+ }, patch.Ins, "Patch ins part")
+ actual := Patch(source, patch)
+ testutils.AssertSame(t, target, actual, "Target obtained from patch application")
+}