9func TestDecodeReader(t *testing.T) {
10 check := func(charset, input, output string) {
12 buf, err := io.ReadAll(DecodeReader(charset, strings.NewReader(input)))
13 tcheck(t, err, "decode")
14 if string(buf) != output {
15 t.Fatalf("decoding %q with charset %q, got %q, expected %q", input, charset, buf, output)
19 check("", "☺", "☺") // No decoding.
20 check("us-ascii", "☺", "☺") // No decoding.
21 check("utf-8", "☺", "☺")
22 check("iso-8859-1", string([]byte{0xa9}), "©")
23 check("iso-8859-5", string([]byte{0xd0}), "а")