🚧 Add Defrag function
This commit is contained in:
parent
2f165369cc
commit
932e8e2f11
7 changed files with 136 additions and 1 deletions
31
blocks_test.go
Normal file
31
blocks_test.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package defrag
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type tt struct {
|
||||
name string
|
||||
diskMap []byte
|
||||
blocks []byte
|
||||
defragged []byte
|
||||
}
|
||||
|
||||
func sampleTests() []tt {
|
||||
return []tt{
|
||||
{"short", []byte("12345"), []byte("0..111....22222"), []byte("022111222......")},
|
||||
{"longer", []byte("2333133121414131402"), []byte("00...111...2...333.44.5555.6666.777.888899"), []byte("0099811188827773336446555566..............")},
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlocks(t *testing.T) {
|
||||
for _, testcase := range sampleTests() {
|
||||
t.Run(testcase.name, func(sub *testing.T) {
|
||||
blocks, err := Blocks(testcase.diskMap)
|
||||
require.NoError(sub, err)
|
||||
require.Equal(sub, testcase.blocks, blocks)
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue