MCPcopy
hub / github.com/syncthing/syncthing / TestLZ4CompressionUpdate

Function TestLZ4CompressionUpdate

lib/protocol/protocol_test.go:343–371  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

341}
342
343func TestLZ4CompressionUpdate(t *testing.T) {
344 uncompressed := []byte("this is some arbitrary yet fairly compressible data")
345
346 // Compressed, as created by the LZ4 implementation in Syncthing 1.18.6 and earlier.
347 oldCompressed, _ := hex.DecodeString("00000033f0247468697320697320736f6d65206172626974726172792079657420666169726c7920636f6d707265737369626c652064617461")
348
349 // Verify that we can decompress
350
351 res, err := lz4Decompress(oldCompressed)
352 if err != nil {
353 t.Fatal(err)
354 }
355 if !bytes.Equal(uncompressed, res) {
356 t.Fatal("result does not match")
357 }
358
359 // Verify that our current compression is equivalent
360
361 buf := make([]byte, 128)
362 n, err := lz4Compress(uncompressed, buf)
363 if err != nil {
364 t.Fatal(err)
365 }
366 if !bytes.Equal(oldCompressed, buf[:n]) {
367 t.Logf("%x", oldCompressed)
368 t.Logf("%x", buf[:n])
369 t.Fatal("compression does not match")
370 }
371}
372
373func TestCheckFilename(t *testing.T) {
374 cases := []struct {

Callers

nothing calls this directly

Calls 4

lz4DecompressFunction · 0.85
lz4CompressFunction · 0.85
FatalMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected