@@ -85,7 +85,7 @@ func TestEncoder_EncodeAllSimple(t *testing.T) {
8585 defer e .Close ()
8686 start := time .Now ()
8787 dst := e .EncodeAll (in , nil )
88- t .Log ("Simple Encoder len" , len (in ), "-> zstd len" , len (dst ))
88+ // t.Log("Simple Encoder len", len(in), "-> zstd len", len(dst))
8989 mbpersec := (float64 (len (in )) / (1024 * 1024 )) / (float64 (time .Since (start )) / (float64 (time .Second )))
9090 t .Logf ("Encoded %d bytes with %.2f MB/s" , len (in ), mbpersec )
9191
@@ -98,7 +98,7 @@ func TestEncoder_EncodeAllSimple(t *testing.T) {
9898 os .WriteFile ("testdata/" + t .Name ()+ "-z000028.want" , in , os .ModePerm )
9999 t .Fatal ("Decoded does not match" )
100100 }
101- t .Log ("Encoded content matched" )
101+ // t.Log("Encoded content matched")
102102 })
103103 }
104104}
@@ -136,6 +136,9 @@ func TestEncoder_EncodeAllConcurrent(t *testing.T) {
136136 go func () {
137137 defer wg .Done ()
138138 dst := e .EncodeAll (in , nil )
139+ if len (dst ) > e .MaxEncodedSize (len (in )) {
140+ t .Errorf ("max encoded size for %v: got: %d, want max: %d" , len (in ), len (dst ), e .MaxEncodedSize (len (in )))
141+ }
139142 //t.Log("Simple Encoder len", len(in), "-> zstd len", len(dst))
140143 decoded , err := dec .DecodeAll (dst , nil )
141144 if err != nil {
@@ -150,7 +153,7 @@ func TestEncoder_EncodeAllConcurrent(t *testing.T) {
150153 }()
151154 }
152155 wg .Wait ()
153- t .Log ("Encoded content matched." , n , "goroutines" )
156+ // t.Log("Encoded content matched.", n, "goroutines")
154157 })
155158 }
156159}
@@ -185,7 +188,10 @@ func TestEncoder_EncodeAllEncodeXML(t *testing.T) {
185188 defer e .Close ()
186189 start := time .Now ()
187190 dst := e .EncodeAll (in , nil )
188- t .Log ("Simple Encoder len" , len (in ), "-> zstd len" , len (dst ))
191+ if len (dst ) > e .MaxEncodedSize (len (in )) {
192+ t .Errorf ("max encoded size for %v: got: %d, want max: %d" , len (in ), len (dst ), e .MaxEncodedSize (len (in )))
193+ }
194+ //t.Log("Simple Encoder len", len(in), "-> zstd len", len(dst))
189195 mbpersec := (float64 (len (in )) / (1024 * 1024 )) / (float64 (time .Since (start )) / (float64 (time .Second )))
190196 t .Logf ("Encoded %d bytes with %.2f MB/s" , len (in ), mbpersec )
191197
@@ -198,7 +204,7 @@ func TestEncoder_EncodeAllEncodeXML(t *testing.T) {
198204 t .Error ("Decoded does not match" )
199205 return
200206 }
201- t .Log ("Encoded content matched" )
207+ // t.Log("Encoded content matched")
202208 })
203209 }
204210}
@@ -250,6 +256,9 @@ func TestEncoderRegression(t *testing.T) {
250256 t .Error (err )
251257 }
252258 encoded := enc .EncodeAll (in , nil )
259+ if len (encoded ) > enc .MaxEncodedSize (len (in )) {
260+ t .Errorf ("max encoded size for %v: got: %d, want max: %d" , len (in ), len (encoded ), enc .MaxEncodedSize (len (in )))
261+ }
253262 // Usually too small...
254263 got , err := dec .DecodeAll (encoded , make ([]byte , 0 , len (in )))
255264 if err != nil {
@@ -268,6 +277,9 @@ func TestEncoderRegression(t *testing.T) {
268277 t .Error (err )
269278 }
270279 encoded = dst .Bytes ()
280+ if len (encoded ) > enc .MaxEncodedSize (len (in )) {
281+ t .Errorf ("max encoded size for %v: got: %d, want max: %d" , len (in ), len (encoded ), enc .MaxEncodedSize (len (in )))
282+ }
271283 got , err = dec .DecodeAll (encoded , make ([]byte , 0 , len (in )/ 2 ))
272284 if err != nil {
273285 t .Logf ("error: %v\n want: %v\n got: %v" , err , in , got )
0 commit comments