Skip to content

Commit fdedec8

Browse files
committed
feat: Add comprehensive tests for Advanced Compression API
- Test all compression parameters (levels, window log, hash log, etc.) - Test all compression strategies (fast, greedy, lazy, btopt, etc.) - Test reset functionality with different directives - Test pledged source size functionality - Test multi-threading parameters (nbWorkers, jobSize, overlapLog) - Add validation for boolean parameters (must be 0 or 1) - Fix ZSTD_c_checksumFlag validation to properly reject value 2
1 parent 4141e62 commit fdedec8

File tree

2 files changed

+426
-0
lines changed

2 files changed

+426
-0
lines changed

gozstd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ func (cctx *CCtx) Reset(reset ZSTD_ResetDirective) error {
135135

136136
// SetParameter sets compression parameters for the given context
137137
func (cctx *CCtx) SetParameter(param CParameter, value int) error {
138+
// Validate boolean parameters
139+
switch param {
140+
case ZSTD_c_checksumFlag, ZSTD_c_contentSizeFlag, ZSTD_c_dictIDFlag:
141+
if value != 0 && value != 1 {
142+
return fmt.Errorf("invalid value %d for boolean parameter %v: must be 0 or 1", value, param)
143+
}
144+
}
145+
138146
result := C.ZSTD_CCtx_setParameter(cctx.cctx,
139147
C.ZSTD_cParameter(param), C.int(value))
140148
isErr := C.ZSTD_isError(C.size_t(result))

0 commit comments

Comments
 (0)