| 6 | ) |
| 7 | |
| 8 | func TestTextMarshal(t *testing.T) { |
| 9 | dataSet := []interface{}{ |
| 10 | 42, |
| 11 | int8(42), |
| 12 | int16(42), |
| 13 | int32(42), |
| 14 | int64(42), |
| 15 | uint(42), |
| 16 | uint8(42), |
| 17 | uint16(42), |
| 18 | uint32(42), |
| 19 | uint64(42), |
| 20 | "42", |
| 21 | testData{}, |
| 22 | &testData{}, |
| 23 | } |
| 24 | |
| 25 | marshaller := &textMarshaller{} |
| 26 | for _, v := range dataSet { |
| 27 | t.Run(reflect.TypeOf(v).Name(), func(t *testing.T) { |
| 28 | result, err := marshaller.Marshal(v) |
| 29 | if err != nil { |
| 30 | t.Fatal(err) |
| 31 | } |
| 32 | if string(result) != "42" { |
| 33 | t.Fatalf("unexpected marshal result: %s", result) |
| 34 | } |
| 35 | }) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | type testData struct{} |
| 40 | |