Skip to content

Commit

Permalink
Adding test case for false-positive in TestCircular
Browse files Browse the repository at this point in the history
  • Loading branch information
yazgazan committed Nov 7, 2018
1 parent 3ebb566 commit f993f5d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions diff/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,11 @@ func TestCircular(t *testing.T) {
1: map[int]interface{}{},
}

repeatingNotCyclic := map[int]interface{}{
0: []interface{}{"foo", "bar"},
}
repeatingNotCyclic[1] = repeatingNotCyclic[0]

for _, test := range []struct {
lhs interface{}
rhs interface{}
Expand All @@ -646,13 +651,18 @@ func TestCircular(t *testing.T) {
{lhs: first, rhs: second, wantError: true},
{lhs: first, rhs: notCyclic, wantError: true},
{lhs: notCyclic, rhs: first, wantError: true},
{lhs: notCyclic, rhs: emptySlice, wantError: false},
{lhs: notCyclic, rhs: emptyMap, wantError: false},
{lhs: notCyclic, rhs: emptySlice},
{lhs: notCyclic, rhs: emptyMap},
{lhs: notCyclic, rhs: notCyclic},
{lhs: emptySlice, rhs: emptySliceNotRepeating},
{lhs: emptySliceNotRepeating, rhs: emptySlice},
{lhs: emptyMap, rhs: emptyMapNotRepeating},
{lhs: emptyMapNotRepeating, rhs: emptyMap},

// Known limitation: our circular reference detection can
// give false-positive when an addressable value is repeated
// in a non-circular pattern.
{lhs: notCyclic, rhs: repeatingNotCyclic, wantError: true},
} {
d, err := Diff(test.lhs, test.rhs)

Expand Down

0 comments on commit f993f5d

Please # to comment.