Extend TestLatestMapMerge()

Add a test case where one input is longer than the other; also run
each case both ways round.

Omit the case which was already the reverse of another.
This commit is contained in:
Bryan Boreham
2018-06-27 08:20:37 +00:00
parent c96611b13d
commit d60f3030ca

View File

@@ -93,13 +93,6 @@ func TestLatestMapMerge(t *testing.T) {
want: MakeStringLatestMap().
Set("foo", now, "bar"),
},
"Empty b": {
a: MakeStringLatestMap().
Set("foo", now, "bar"),
b: MakeStringLatestMap(),
want: MakeStringLatestMap().
Set("foo", now, "bar"),
},
"Disjoint a & b": {
a: MakeStringLatestMap().
Set("foo", now, "bar"),
@@ -117,10 +110,26 @@ func TestLatestMapMerge(t *testing.T) {
want: MakeStringLatestMap().
Set("foo", now, "bar"),
},
"Longer": {
a: MakeStringLatestMap().
Set("PID", now, "23128").
Set("Name", now, "curl"),
b: MakeStringLatestMap().
Set("PID", then, "0").
Set("Name", now, "curl").
Set("Domain", now, "node-a.local"),
want: MakeStringLatestMap().
Set("PID", now, "23128").
Set("Name", now, "curl").
Set("Domain", now, "node-a.local"),
},
} {
if have := c.a.Merge(c.b); !reflect.DeepEqual(c.want, have) {
t.Errorf("%s:\n%s", name, test.Diff(c.want, have))
}
if have := c.b.Merge(c.a); !reflect.DeepEqual(c.want, have) {
t.Errorf("%s:\n%s", name, test.Diff(c.want, have))
}
}
}