twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

stdlibfuzz.go (1000B)


      1 // Code generated by gen.go. DO NOT EDIT.
      2 
      3 // Copyright 2019 The Go Authors. All rights reserved.
      4 // Use of this source code is governed by a BSD-style
      5 // license that can be found in the LICENSE file.
      6 
      7 // +build gofuzz
      8 
      9 package png
     10 
     11 import (
     12 	"bytes"
     13 	"fmt"
     14 )
     15 
     16 func Fuzz(data []byte) int {
     17 	cfg, err := DecodeConfig(bytes.NewReader(data))
     18 	if err != nil {
     19 		return 0
     20 	}
     21 	if cfg.Width*cfg.Height > 1e6 {
     22 		return 0
     23 	}
     24 	img, err := Decode(bytes.NewReader(data))
     25 	if err != nil {
     26 		return 0
     27 	}
     28 	levels := []CompressionLevel{
     29 		DefaultCompression,
     30 		NoCompression,
     31 		BestSpeed,
     32 		BestCompression,
     33 	}
     34 	for _, l := range levels {
     35 		var w bytes.Buffer
     36 		e := &Encoder{CompressionLevel: l}
     37 		err = e.Encode(&w, img)
     38 		if err != nil {
     39 			panic(err)
     40 		}
     41 		img1, err := Decode(&w)
     42 		if err != nil {
     43 			panic(err)
     44 		}
     45 		got := img1.Bounds()
     46 		want := img.Bounds()
     47 		if !got.Eq(want) {
     48 			fmt.Printf("bounds0: %#v\n", want)
     49 			fmt.Printf("bounds1: %#v\n", got)
     50 			panic("bounds have changed")
     51 		}
     52 	}
     53 	return 1
     54 }