aboutsummaryrefslogtreecommitdiffstats
path: root/skate/zippy_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'skate/zippy_test.go')
-rw-r--r--skate/zippy_test.go61
1 files changed, 60 insertions, 1 deletions
diff --git a/skate/zippy_test.go b/skate/zippy_test.go
index 3c1911c..4c9ed32 100644
--- a/skate/zippy_test.go
+++ b/skate/zippy_test.go
@@ -277,7 +277,7 @@ func TestRemoveSelfLinks(t *testing.T) {
},
{
brefs: []*BiblioRef{},
- result: nil,
+ result: []*BiblioRef{},
},
{
brefs: []*BiblioRef{
@@ -308,3 +308,62 @@ func TestRemoveSelfLinks(t *testing.T) {
}
}
}
+
+func TestDeduplicateBrefs(t *testing.T) {
+ var cases = []struct {
+ brefs []*BiblioRef
+ result []*BiblioRef
+ }{
+ {
+ brefs: nil,
+ result: nil,
+ },
+ {
+ brefs: []*BiblioRef{},
+ result: nil,
+ },
+ {
+ brefs: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ &BiblioRef{Key: "123", MatchStatus: StatusExact.Short()},
+ },
+ result: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusExact.Short()},
+ },
+ },
+ {
+ brefs: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ &BiblioRef{Key: "123", MatchStatus: StatusUnmatched.Short()},
+ },
+ result: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ },
+ },
+ {
+ brefs: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ &BiblioRef{Key: "123", MatchStatus: StatusWeak.Short()},
+ },
+ result: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ },
+ },
+ {
+ brefs: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ &BiblioRef{Key: "123", MatchStatus: StatusAmbiguous.Short()},
+ },
+ result: []*BiblioRef{
+ &BiblioRef{Key: "123", MatchStatus: StatusStrong.Short()},
+ },
+ },
+ }
+ for i, c := range cases {
+ result := deduplicateBrefs(c.brefs)
+ if !reflect.DeepEqual(result, c.result) {
+ t.Fatalf("[%d]: got %v, want %v (%v)",
+ i, result, c.result, pretty.Diff(result, c.result))
+ }
+ }
+}