-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
48 lines (37 loc) · 997 Bytes
/
main_test.go
File metadata and controls
48 lines (37 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"testing"
)
type MockFileSystem struct {
next uint64
}
type MockFragment struct {
data string
start uint64
length uint64
}
type MockFile struct {
fragments []MockFragment
}
// creates a new fragment on the virtual disk with the characters of the given string
// representing the contents of the block. The fragment is not adjacent to any other
// fragment.
func (fs *MockFileSystem) fragment(data string) MockFragment {
fragment := MockFragment{data: data, start: fs.next, length: uint64(len(data))}
fs.next = fragment.start + fragment.length + 1
return fragment
}
func (fs *MockFileSystem) file(frags ...MockFragment) MockFile {
return MockFile{fragments: frags}
}
func assertDefragResult(defraggedSize uint64, files ...MockFile) {
// TODO implement assertion
}
func TestSubmitForDefrag(t *testing.T) {
var fs MockFileSystem
a1 := fs.fragment("abc")
a2 := fs.fragment("abc")
f1 := fs.file(a1)
f2 := fs.file(a2)
assertDefragResult(3, f1, f2)
}