(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestReplacement(t *testing.T) { |
| 55 | for _, direction := range []string{"Decode", "Encode"} { |
| 56 | enc, want := (transform.Transformer)(nil), "" |
| 57 | if direction == "Decode" { |
| 58 | enc = encoding.Replacement.NewDecoder() |
| 59 | want = "\ufffd" |
| 60 | } else { |
| 61 | enc = encoding.Replacement.NewEncoder() |
| 62 | want = "AB\x00CD\ufffdYZ" |
| 63 | } |
| 64 | sr := strings.NewReader("AB\x00CD\x80YZ") |
| 65 | g, err := io.ReadAll(transform.NewReader(sr, enc)) |
| 66 | if err != nil { |
| 67 | t.Errorf("%s: ReadAll: %v", direction, err) |
| 68 | continue |
| 69 | } |
| 70 | if got := string(g); got != want { |
| 71 | t.Errorf("%s:\ngot %q\nwant %q", direction, got, want) |
| 72 | continue |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | func TestUTF8Validator(t *testing.T) { |
| 78 | testCases := []struct { |
nothing calls this directly
no test coverage detected