From d60f3030ca25b194f31492b18d1311627687c731 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 27 Jun 2018 08:20:37 +0000 Subject: [PATCH] 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. --- report/latest_map_internal_test.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/report/latest_map_internal_test.go b/report/latest_map_internal_test.go index e20e54038..70ca27a7d 100644 --- a/report/latest_map_internal_test.go +++ b/report/latest_map_internal_test.go @@ -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)) + } } }