| 1 | package fsutilscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.21 bytes/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.21 testing/" |
| 6 | |
| 7 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/" |
| 8 | ) |
| 9 | |
| 10 | func TestAllocAndBytesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestAllocAndBytes().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 11 | buf := &bufferscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#{} |
| 12 | |
| 13 | out1 := buf.allocscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#alloc().(10) |
| 14 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Lenscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Len().(t, out1, 10) |
| 15 | copy(out1, []byte("abcdefghij")) |
| 16 | |
| 17 | out2 := buf.allocscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#alloc().(5) |
| 18 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Lenscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Len().(t, out2, 5) |
| 19 | copy(out2, []byte("12345")) |
| 20 | |
| 21 | res := &bytesscip-go gomod github.com/golang/go/src go1.21 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#{} |
| 22 | n, err := buf.WriteToscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#WriteTo().(res) |
| 23 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 24 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, int64(15), n) |
| 25 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, []byte("abcdefghij12345"), res.Bytesscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#Bytes().()) |
| 26 | } |
| 27 | |
| 28 | func TestLargeAllocGetsOwnChunkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestLargeAllocGetsOwnChunk().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 29 | buf := &bufferscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#{} |
| 30 | |
| 31 | out := buf.allocscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#alloc().(100000) |
| 32 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Lenscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Len().(t, out, 100000) |
| 33 | |
| 34 | for i := range out { |
| 35 | out[i] = byte(i % 256) |
| 36 | } |
| 37 | |
| 38 | res := &bytesscip-go gomod github.com/golang/go/src go1.21 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#{} |
| 39 | n, err := buf.WriteToscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#WriteTo().(res) |
| 40 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 41 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, int64(100000), n) |
| 42 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, 100000, res.Lenscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#Len().()) |
| 43 | } |
| 44 | |
| 45 | func TestMultipleChunkBoundaryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestMultipleChunkBoundary().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 46 | buf := &bufferscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#{} |
| 47 | |
| 48 | var written []byte |
| 49 | for i := 0; i < 100; i++ { |
| 50 | b := buf.allocscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#alloc().(400) |
| 51 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Lenscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Len().(t, b, 400) |
| 52 | for j := range b { |
| 53 | b[j] = byte((i + j) % 256) |
| 54 | } |
| 55 | written = append(written, b...) |
| 56 | } |
| 57 | |
| 58 | res := &bytesscip-go gomod github.com/golang/go/src go1.21 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#{} |
| 59 | n, err := buf.WriteToscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/buffer#WriteTo().(res) |
| 60 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 61 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, int64(40000), n) |
| 62 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, 40000, res.Lenscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#Len().()) |
| 63 | dt := res.Bytesscip-go gomod github.com/golang/go/src go1.21 bytes/Buffer#Bytes().() |
| 64 | for i := 0; i < 100; i++ { |
| 65 | for j := 0; j < 400; j++ { |
| 66 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, byte((i+j)%256), dt[i*400+j]) |
| 67 | } |
| 68 | } |
| 69 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/Equal().(t, written, dt) |
| 70 | } |