github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/ais/s3/xattr_internal_test.go (about) 1 // Package s3 provides Amazon S3 compatibility layer 2 /* 3 * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package s3 6 7 import ( 8 "testing" 9 10 "github.com/NVIDIA/aistore/tools/trand" 11 ) 12 13 func TestPackUnpack(t *testing.T) { 14 const nump = 10 15 var ( 16 in = mpt{parts: make([]*MptPart, 0)} 17 out = &mpt{} 18 ) 19 for i := range nump { 20 in.parts = append(in.parts, &MptPart{Num: int32(111 + i*i), MD5: trand.String(8), Size: 1024 + int64(i)}) 21 } 22 b := in.pack() 23 if err := out.unpack(b); err != nil { 24 t.Fatal(err) 25 } 26 if len(in.parts) != len(out.parts) { 27 t.Fatalf("in != out: %d, %d", len(in.parts), len(out.parts)) 28 } 29 for i := range nump { 30 if *in.parts[i] != *out.parts[i] { 31 t.Fatalf("in %v != out %v", *in.parts[i], *out.parts[i]) 32 } 33 } 34 }