From 3e83fcc2181962c1af868b3de2e08b5825ffad0f Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 21 Nov 2019 15:12:52 +0100 Subject: [PATCH] TestValueEquals: also test through gob encoding --- cty/value_ops_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cty/value_ops_test.go b/cty/value_ops_test.go index 471e99a4..5abf2230 100644 --- a/cty/value_ops_test.go +++ b/cty/value_ops_test.go @@ -1,6 +1,8 @@ package cty import ( + "bytes" + "encoding/gob" "fmt" "math/big" "reflect" @@ -668,6 +670,21 @@ func TestValueEquals(t *testing.T) { t.Fatalf("Equals returned %#v; want %#v", got, test.Expected) } }) + t.Run(fmt.Sprintf("gob %#v.Equals(%#v)", test.LHS, test.RHS), func(t *testing.T) { + b := bytes.NewBuffer(nil) + err := gob.NewEncoder(b).Encode(test.RHS) + if err != nil { + t.Fatalf("Failed to gob Encode: %v", err) + } + var RHS Value + if err := gob.NewDecoder(b).Decode(&RHS); err != nil { + t.Fatalf("Failed to gob Encode: %v", err) + } + got := test.LHS.Equals(RHS) + if !got.RawEquals(test.Expected) { + t.Fatalf("Equals returned %#v; want %#v", got, test.Expected) + } + }) } }