MCPcopy
hub / github.com/klauspost/compress / testSnappyBlockRoundtrip

Function testSnappyBlockRoundtrip

s2/s2_test.go:1312–1365  ·  view source on GitHub ↗
(t *testing.T, src []byte)

Source from the content-addressed store, hash-verified

1310}
1311
1312func testSnappyBlockRoundtrip(t *testing.T, src []byte) {
1313 // Write with s2, decode with snapref.
1314 t.Run("regular", func(t *testing.T) {
1315 dst := EncodeSnappy(nil, src)
1316 t.Logf("encoded to %d -> %d bytes", len(src), len(dst))
1317 decoded, err := snapref.Decode(nil, dst)
1318 if err != nil {
1319 t.Error(err)
1320 return
1321 }
1322 if len(decoded) != len(src) {
1323 t.Error("decoded len:", len(decoded), "!=", len(src))
1324 return
1325 }
1326 err = cmp(src, decoded)
1327 if err != nil {
1328 t.Error(err)
1329 }
1330 })
1331 t.Run("better", func(t *testing.T) {
1332 dst := EncodeSnappyBetter(nil, src)
1333 t.Logf("encoded to %d -> %d bytes", len(src), len(dst))
1334 decoded, err := snapref.Decode(nil, dst)
1335 if err != nil {
1336 t.Error(err)
1337 return
1338 }
1339 if len(decoded) != len(src) {
1340 t.Error("decoded len:", len(decoded), "!=", len(src))
1341 return
1342 }
1343 err = cmp(src, decoded)
1344 if err != nil {
1345 t.Error(err)
1346 }
1347 })
1348 t.Run("best", func(t *testing.T) {
1349 dst := EncodeSnappyBest(nil, src)
1350 t.Logf("encoded to %d -> %d bytes", len(src), len(dst))
1351 decoded, err := snapref.Decode(nil, dst)
1352 if err != nil {
1353 t.Error(err)
1354 return
1355 }
1356 if len(decoded) != len(src) {
1357 t.Error("decoded len:", len(decoded), "!=", len(src))
1358 return
1359 }
1360 err = cmp(src, decoded)
1361 if err != nil {
1362 t.Error(err)
1363 }
1364 })
1365}
1366
1367func testSnappyDecode(t *testing.T, src []byte) {
1368 var buf bytes.Buffer

Callers 2

testFileFunction · 0.85
TestDataRoundtripsFunction · 0.85

Calls 6

DecodeFunction · 0.92
EncodeSnappyFunction · 0.85
EncodeSnappyBetterFunction · 0.85
EncodeSnappyBestFunction · 0.85
cmpFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…