func TestDecodeRawPPM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(ppmRaw))
	defer r.Close()
	img, str, err := image.Decode(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "ppm" {
		t.Fatalf("Expected ppm but received %s", str)
	}
	nimg, ok := img.(Image)
	if !ok {
		t.Fatal("Image is not a Netppm image")
	}
	if nimg.MaxValue() != 255 {
		t.Fatalf("Expected a maximum value of 255 but received %d", nimg.MaxValue())
	}
}
TestDecodeRawPPM determines if image.Decode can decode a raw PPM file.
package netpbm
import (
	"bytes"
	"compress/flate"
	"image"
	"testing"
)
func TestDecodeRawPBMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmRaw))
	defer r.Close()
	cfg, str, err := image.DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pbm" {
		t.Fatalf("Expected \"pbm\" but received %q", str)
	}
	if cfg.Width != 64 || cfg.Height != 64 {
		t.Fatalf("Expected a 64x64 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestDecodeRawPBM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmRaw))
	defer r.Close()
	img, str, err := image.Decode(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pbm" {
		t.Fatalf("Expected pbm but received %s", str)
	}
	nimg, ok := img.(Image)
	if !ok {
		t.Fatal("Image is not a Netpbm image")
	}
	if nimg.MaxValue() != 1 {
		t.Fatalf("Expected a maximum value of 1 but received %d", nimg.MaxValue())
	}
}
func TestNetpbmDecodeRawPBMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmRaw))
	defer r.Close()
	cfg, err := DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if cfg.Width != 64 || cfg.Height != 64 {
		t.Fatalf("Expected a 64x64 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestNetpbmDecodeRawPBM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmRaw))
	defer r.Close()
	img, err := Decode(r, nil)
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PBM {
		t.Fatalf("Expected PBM but received %s", img.Format())
	}
	if img.MaxValue() != 1 {
		t.Fatalf("Expected a maximum value of 1 but received %d", img.MaxValue())
	}
}
func TestNetpbmDecodeRawPBMOpts(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmRaw))
	defer r.Close()
	img, err := Decode(r, &DecodeOptions{
		Target: PBM,
		Exact:  true,
	})
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PBM {
		t.Fatalf("Expected PBM but received %s", img.Format())
	}
}
func TestNetpbmEncodeRawPBM(t *testing.T) {
	repeatDecodeEncode(t, pbmRaw, nil, nil)
}
func TestNetpbmEncodeRawPBMAsPNM(t *testing.T) {
	dOpts := &DecodeOptions{Target: PNM}
	eOpts := &EncodeOptions{Format: PNM}
	repeatDecodeEncode(t, pbmRaw, dOpts, eOpts)
}
func TestDecodePlainPBMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmPlain))
	defer r.Close()
	cfg, str, err := image.DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pbm" {
		t.Fatalf("Expected \"pbm\" but received %q", str)
	}
	if cfg.Width != 63 || cfg.Height != 65 {
		t.Fatalf("Expected a 63x65 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestDecodePlainPBM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmPlain))
	defer r.Close()
	img, str, err := image.Decode(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pbm" {
		t.Fatalf("Expected pbm but received %s", str)
	}
	nimg, ok := img.(Image)
	if !ok {
		t.Fatal("Image is not a Netpbm image")
	}
	if nimg.MaxValue() != 1 {
		t.Fatalf("Expected a maximum value of 1 but received %d", nimg.MaxValue())
	}
}
func TestNetpbmDecodePlainPBMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmPlain))
	defer r.Close()
	cfg, err := DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if cfg.Width != 63 || cfg.Height != 65 {
		t.Fatalf("Expected a 63x65 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestNetpbmDecodePlainPBM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmPlain))
	defer r.Close()
	img, err := Decode(r, nil)
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PBM {
		t.Fatalf("Expected PBM but received %s", img.Format())
	}
	if img.MaxValue() != 1 {
		t.Fatalf("Expected a maximum value of 1 but received %d", img.MaxValue())
	}
}
func TestNetpbmDecodePlainPBMOpts(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pbmPlain))
	defer r.Close()
	img, err := Decode(r, &DecodeOptions{
		Target: PBM,
		Exact:  true,
	})
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PBM {
		t.Fatalf("Expected PBM but received %s", img.Format())
	}
}
func TestNetpbmEncodePlainPBM(t *testing.T) {
	repeatDecodeEncode(t, pbmPlain, nil, nil)
}
func TestNetpbmEncodePlainPBMAsPNM(t *testing.T) {
	dOpts := &DecodeOptions{Target: PNM}
	eOpts := &EncodeOptions{Format: PNM}
	repeatDecodeEncode(t, pbmPlain, dOpts, eOpts)
}
func TestDecodeRawPGMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmRaw))
	defer r.Close()
	cfg, str, err := image.DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pgm" {
		t.Fatalf("Expected \"pgm\" but received %q", str)
	}
	if cfg.Width != 64 || cfg.Height != 64 {
		t.Fatalf("Expected a 64x64 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestDecodeRawPGM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmRaw))
	defer r.Close()
	img, str, err := image.Decode(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pgm" {
		t.Fatalf("Expected pgm but received %s", str)
	}
	nimg, ok := img.(Image)
	if !ok {
		t.Fatal("Image is not a Netpgm image")
	}
	if nimg.MaxValue() != 255 {
		t.Fatalf("Expected a maximum value of 255 but received %d", nimg.MaxValue())
	}
}
func TestNetpbmDecodeRawPGMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmRaw))
	defer r.Close()
	cfg, err := DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if cfg.Width != 64 || cfg.Height != 64 {
		t.Fatalf("Expected a 64x64 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestNetpbmDecodeRawPGM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmRaw))
	defer r.Close()
	img, err := Decode(r, nil)
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PGM {
		t.Fatalf("Expected PGM but received %s", img.Format())
	}
	if img.MaxValue() != 255 {
		t.Fatalf("Expected a maximum value of 255 but received %d", img.MaxValue())
	}
}
func TestNetpbmDecodeRawPGMOpts(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmRaw))
	defer r.Close()
	img, err := Decode(r, &DecodeOptions{
		Target: PGM,
		Exact:  true,
	})
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PGM {
		t.Fatalf("Expected PGM but received %s", img.Format())
	}
}
func TestNetpbmEncodeRawPGM(t *testing.T) {
	repeatDecodeEncode(t, pgmRaw, nil, nil)
}
func TestNetpbmEncodeRawPGMAsPNM(t *testing.T) {
	dOpts := &DecodeOptions{Target: PNM}
	eOpts := &EncodeOptions{Format: PNM}
	repeatDecodeEncode(t, pgmRaw, dOpts, eOpts)
}
func TestDecodePlainPGMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmPlain))
	defer r.Close()
	cfg, str, err := image.DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pgm" {
		t.Fatalf("Expected \"pgm\" but received %q", str)
	}
	if cfg.Width != 63 || cfg.Height != 65 {
		t.Fatalf("Expected a 63x65 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestDecodePlainPGM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmPlain))
	defer r.Close()
	img, str, err := image.Decode(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "pgm" {
		t.Fatalf("Expected pgm but received %s", str)
	}
	nimg, ok := img.(Image)
	if !ok {
		t.Fatal("Image is not a Netpgm image")
	}
	if nimg.MaxValue() != 777 {
		t.Fatalf("Expected a maximum value of 777 but received %d", nimg.MaxValue())
	}
}
func TestNetpbmDecodePlainPGMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmPlain))
	defer r.Close()
	cfg, err := DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if cfg.Width != 63 || cfg.Height != 65 {
		t.Fatalf("Expected a 63x65 image but received %dx%d", cfg.Width, cfg.Height)
	}
}
func TestNetpbmDecodePlainPGM(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmPlain))
	defer r.Close()
	img, err := Decode(r, nil)
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PGM {
		t.Fatalf("Expected PGM but received %s", img.Format())
	}
	if img.MaxValue() != 777 {
		t.Fatalf("Expected a maximum value of 777 but received %d", img.MaxValue())
	}
}
func TestNetpbmDecodePlainPGMOpts(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(pgmPlain))
	defer r.Close()
	img, err := Decode(r, &DecodeOptions{
		Target: PGM,
		Exact:  true,
	})
	if err != nil {
		t.Fatal(err)
	}
	if img.Format() != PGM {
		t.Fatalf("Expected PGM but received %s", img.Format())
	}
}
func TestNetpbmEncodePlainPGM(t *testing.T) {
	repeatDecodeEncode(t, pgmPlain, nil, nil)
}
func TestNetpbmEncodePlainPGMAsPNM(t *testing.T) {
	dOpts := &DecodeOptions{Target: PNM}
	eOpts := &EncodeOptions{Format: PNM}
	repeatDecodeEncode(t, pgmPlain, dOpts, eOpts)
}
func TestDecodeRawPPMConfig(t *testing.T) {
	r := flate.NewReader(bytes.NewBufferString(ppmRaw))
	defer r.Close()
	cfg, str, err := image.DecodeConfig(r)
	if err != nil {
		t.Fatal(err)
	}
	if str != "ppm" {
		t.Fatalf("Expected \"ppm\" but received %q", str)
	}
	if cfg.Width != 64 || cfg.Height != 64 {
		t.Fatalf("Expected a 64x64 image but received %dx%d", cfg.Width, cfg.Height)
	}
}