lostluck commented on a change in pull request #11926:
URL: https://github.com/apache/beam/pull/11926#discussion_r436032240



##########
File path: sdks/go/pkg/beam/coder_test.go
##########
@@ -63,3 +64,57 @@ func TestJSONCoder(t *testing.T) {
                }
        }
 }
+
+func TestCoders(t *testing.T) {
+       ptrString := "test *string"
+       tests := []interface{}{
+               43,
+               12431235,
+               -2,
+               0,
+               1,
+               true,
+               "a string",
+               map[int64]string{1: "one", 11: "oneone", 21: "twoone", 1211: 
"onetwooneone"},
+               struct {
+                       A int
+                       B *string
+                       C bool
+               }{4, &ptrString, false},
+               [...]int64{1, 2, 3, 4, 5}, // array
+               []int64{1, 2, 3, 4, 5},    // slice
+               struct {
+                       A []int
+                       B [3]int
+               }{A: []int{1, 2, 3}, B: [...]int{4, 5, 6}},
+       }
+
+       for _, test := range tests {
+               var results []string
+               rt := reflect.TypeOf(test)
+               enc := NewElementEncoder(rt)
+               for i := 0; i < 10; i++ {
+                       var buf bytes.Buffer
+                       if err := enc.Encode(test, &buf); err != nil {
+                               t.Fatalf("Failed to encode %v: %v", tests, err)
+                       }
+                       results = append(results, string(buf.Bytes()))
+               }
+               for i, data := range results {
+                       if data != results[0] {
+                               t.Errorf("coder not deterministic: data[%d]: %v 
!= %v ", i, data, results[0])

Review comment:
       Good catch! Fixed to make it clearer what the test is checking for.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to