add synth_test for cbrotli

PiperOrigin-RevId: 772439037
This commit is contained in:
Evgenii Kliuchnikov
2025-06-17 06:01:41 -07:00
committed by Copybara-Service
parent 3efb30f96b
commit 7bd1bd4463
3 changed files with 2309 additions and 3 deletions

View File

@@ -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"],
)

View File

@@ -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

File diff suppressed because it is too large Load Diff