Skip to content

Commit

Permalink
Merge pull request #6649 from hs0210/work
Browse files Browse the repository at this point in the history
Add unit test for func Proto3ValuesEqual.
  • Loading branch information
harshit-gangal authored Sep 1, 2020
2 parents c8b47c8 + a4af5ca commit a8ba677
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions go/sqltypes/proto3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/require"
querypb "vitess.io/vitess/go/vt/proto/query"
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/vterrors"
Expand Down Expand Up @@ -244,3 +245,78 @@ func TestQueryReponses(t *testing.T) {
t.Errorf("reverse:\n%#v, want\n%#v", reverse, queryResponses)
}
}

func TestProto3ValuesEqual(t *testing.T) {
for _, tc := range []struct {
v1, v2 []*querypb.Value
expected bool
}{
{
v1: []*querypb.Value{
{
Type: 0,
Value: []byte{0, 1},
},
},
v2: []*querypb.Value{
{
Type: 0,
Value: []byte{0, 1},
},
{
Type: 1,
Value: []byte{0, 1, 2},
},
},
expected: false,
},
{
v1: []*querypb.Value{
{
Type: 0,
Value: []byte{0, 1},
},
{
Type: 1,
Value: []byte{0, 1, 2},
},
},
v2: []*querypb.Value{
{
Type: 0,
Value: []byte{0, 1},
},
{
Type: 1,
Value: []byte{0, 1, 2},
},
},
expected: true,
},
{
v1: []*querypb.Value{
{
Type: 0,
Value: []byte{0, 1},
},
{
Type: 1,
Value: []byte{0, 1},
},
},
v2: []*querypb.Value{
{
Type: 0,
Value: []byte{0, 1},
},
{
Type: 1,
Value: []byte{0, 1, 2},
},
},
expected: false,
},
} {
require.Equal(t, tc.expected, Proto3ValuesEqual(tc.v1, tc.v2))
}
}

0 comments on commit a8ba677

Please sign in to comment.