(t *testing.T)
| 341 | } |
| 342 | |
| 343 | func 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 | |
| 373 | func TestCheckFilename(t *testing.T) { |
| 374 | cases := []struct { |
nothing calls this directly
no test coverage detected