Skip to content

Commit

Permalink
TestValueEquals: also test through gob encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
azr committed Nov 21, 2019
1 parent 2eed962 commit 3e83fcc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cty/value_ops_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cty

import (
"bytes"
"encoding/gob"
"fmt"
"math/big"
"reflect"
Expand Down Expand Up @@ -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)
}
})
}
}

Expand Down

0 comments on commit 3e83fcc

Please sign in to comment.