Skip to content

Commit

Permalink
Add a test for issue pixiv#55
Browse files Browse the repository at this point in the history
  • Loading branch information
bayandin committed Aug 21, 2019
1 parent 83566ac commit be09693
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jpeg/issue51_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (
"github.com/pixiv/go-libjpeg/jpeg"
)

var data = []byte("\xff\xd8\xff\xdb\x00C\x000000000000000" +
var data51 = []byte("\xff\xd8\xff\xdb\x00C\x000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000\xff\xc9\x00\v\b00\x000" +
"\x01\x01\x14\x00\xff\xda\x00\b\x01\x010\x00?\x0000")

// https://github.com/pixiv/go-libjpeg/issues/51
func TestIssue51(t *testing.T) {
jpeg.Decode(bytes.NewReader(data), &jpeg.DecoderOptions{})
jpeg.Decode(bytes.NewReader(data51), &jpeg.DecoderOptions{})
}
29 changes: 29 additions & 0 deletions jpeg/issue55_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package jpeg_test

import (
"bytes"
"testing"

"github.com/pixiv/go-libjpeg/jpeg"
)

var data55 = []byte("\xff\xd8\xff\xdb\x00C\x000000000000000" +
"00000000000000000000" +
"00000000000000000000" +
"00000000000\xff\xc0\x00\x11\b\x00000" +
"\x03R\"\x00G\x11\x00B\x11\x00\xff\xda\x00\f\x03R\x00G\x00B" +
"\x00")

// https://github.com/pixiv/go-libjpeg/issues/55
func TestIssue55(t *testing.T) {
img, err := jpeg.Decode(bytes.NewReader(data55), &jpeg.DecoderOptions{})
if err != nil {
return
}

var w bytes.Buffer
err = jpeg.Encode(&w, img, &jpeg.EncoderOptions{})
if err != nil {
t.Errorf("encoding after decoding failed: %v", err)
}
}

0 comments on commit be09693

Please sign in to comment.