diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-21 16:29:44 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-21 16:29:44 +0200 |
commit | 2887d66a939b3b8d7e84d9c71c0a86d5132b5e54 (patch) | |
tree | 763fcf337d7729e894f2f331dca7cbad52298b50 /slice/slice_test.go | |
parent | e3ba94744ed4f22e4a05f0757b624936602b70db (diff) | |
download | dna-backup-2887d66a939b3b8d7e84d9c71c0a86d5132b5e54.tar.gz dna-backup-2887d66a939b3b8d7e84d9c71c0a86d5132b5e54.zip |
change recipe into a generic slice patch/diff package
Diffstat (limited to 'slice/slice_test.go')
-rw-r--r-- | slice/slice_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/slice/slice_test.go b/slice/slice_test.go new file mode 100644 index 0000000..b73946e --- /dev/null +++ b/slice/slice_test.go @@ -0,0 +1,21 @@ +package slice + +import ( + "testing" + + "github.com/n-peugnet/dna-backup/testutils" +) + +func TestPatch(t *testing.T) { + source := Slice{1, 2, 3, 4} + target := Slice{2, 5, 3, 6, 4, 7, 8} + patch := DiffSlice(source, target) + testutils.AssertSame(t, []SliceDel{0}, patch.Del, "Patch del part") + testutils.AssertSame(t, []SliceIns{ + {1, Slice{5}}, + {3, Slice{6}}, + {5, Slice{7, 8}}, + }, patch.Ins, "Patch ins part") + actual := PatchSlice(source, patch) + testutils.AssertSame(t, target, actual, "Target obtained from patch application") +} |