youngoli commented on a change in pull request #13209:
URL: https://github.com/apache/beam/pull/13209#discussion_r514010115



##########
File path: sdks/go/pkg/beam/coder_test.go
##########
@@ -75,46 +134,51 @@ func TestCoders(t *testing.T) {
                1,
                true,
                "a string",
-               map[int64]string{1: "one", 11: "oneone", 21: "twoone", 1211: 
"onetwooneone"},
+               map[int64]string{1: "one", 11: "oneone", 21: "twoone", 1211: 
"onetwooneone"}, // (not supported by custom type registration)
                struct {
                        A int
                        B *string
                        C bool
                }{4, &ptrString, false},
-               [...]int64{1, 2, 3, 4, 5}, // array
+               [...]int64{1, 2, 3, 4, 5}, // array (not supported by custom 
type registration)
                []int64{1, 2, 3, 4, 5},    // slice
                struct {
                        A []int
                        B [3]int
                }{A: []int{1, 2, 3}, B: [...]int{4, 5, 6}},
+               [...]struct{ A int }{{1}, {2}, {3}, {4}, {5}},
+               []struct{ B int }{{1}, {2}, {3}, {4}, {5}},
+               regTestType{[4]int{4, 2, 4, 2}},
        }
 
        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)
+               t.Run(fmt.Sprintf("%T", test), func(t *testing.T) {
+                       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", 
test, err)
+                               }
+                               results = append(results, string(buf.Bytes()))
                        }
-                       results = append(results, string(buf.Bytes()))
-               }
-               for i, d := range results {
-                       if d != results[0] {
-                               t.Errorf("coder not deterministic: encoding %d 
not the same as the first encoding: %v != %v ", i, d, results[0])
+                       for i, d := range results {
+                               if d != results[0] {
+                                       t.Errorf("coder not deterministic: 
encoding %d not the same as the first encoding: %v != %v ", i, d, results[0])
+                               }
                        }
-               }
 
-               dec := NewElementDecoder(rt)
-               buf := bytes.NewBuffer([]byte(results[0]))
-               decoded, err := dec.Decode(buf)
-               if err != nil {
-                       t.Fatalf("Failed to decode: %v", err)
-               }
+                       dec := NewElementDecoder(rt)
+                       buf := bytes.NewBuffer([]byte(results[0]))
+                       decoded, err := dec.Decode(buf)
+                       if err != nil {
+                               t.Fatalf("Failed to decode: %q, into %v", 
results[0], err)

Review comment:
       Is the `%v` in the format string supposed to be the error? It reads like 
it's meant to output the expected decoded value (i.e. `test`).




----------------------------------------------------------------
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