mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
add synth_test for cbrotli
PiperOrigin-RevId: 772439037
This commit is contained in:
committed by
Copybara-Service
parent
3efb30f96b
commit
7bd1bd4463
@@ -24,3 +24,10 @@ go_test(
|
||||
srcs = ["cbrotli_test.go"],
|
||||
deps = [":cbrotli"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "synth_test",
|
||||
size = "small",
|
||||
srcs = ["synth_test.go"],
|
||||
deps = [":cbrotli"],
|
||||
)
|
||||
|
||||
@@ -110,8 +110,13 @@ func (r *Reader) Read(p []byte) (n int, err error) {
|
||||
if int(C.BrotliDecoderHasMoreOutput(r.state)) == 0 && len(r.in) == 0 {
|
||||
m, readErr := r.src.Read(r.buf)
|
||||
if m == 0 {
|
||||
// If readErr is `nil`, we just proxy underlying stream behavior.
|
||||
return 0, readErr
|
||||
if readErr != io.EOF {
|
||||
return 0, readErr
|
||||
}
|
||||
if int(C.BrotliDecoderIsFinished(r.state)) == 0 {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
return 0, io.EOF
|
||||
}
|
||||
r.in = r.buf[:m]
|
||||
}
|
||||
@@ -197,5 +202,9 @@ func DecodeWithRawDictionary(encodedData []byte, dictionary []byte) ([]byte, err
|
||||
pinner: p,
|
||||
}
|
||||
defer r.Close()
|
||||
return ioutil.ReadAll(r)
|
||||
out, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
2290
go/cbrotli/synth_test.go
Normal file
2290
go/cbrotli/synth_test.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user