summaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-04 10:38:58 +0200
committerJakob Unterwurzacher2015-10-04 10:39:44 +0200
commitfa887417708484eee03daf423a96d024960ed524 (patch)
tree86802cdf85530f20a9f55ef6fc0c3578b7b22c36 /main_test.go
parent40448db90971b42d9e5e7b7b7918f36283575759 (diff)
tests: add TestFileHoles
Create a file with holes by writing to offset 0 (block #0) and offset 4096 (block #1). This test currently fails.
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
index 4f51d00..dba3ef1 100644
--- a/main_test.go
+++ b/main_test.go
@@ -178,6 +178,23 @@ func TestAppend(t *testing.T) {
}
}
+// Create a file with holes by writing to offset 0 (block #0) and
+// offset 4096 (block #1).
+func TestFileHoles(t *testing.T) {
+ fn := plainDir + "fileholes"
+ file, err := os.Create(fn)
+ if err != nil {
+ t.Errorf("file create failed")
+ }
+ foo := []byte("foo")
+ file.Write(foo)
+ file.WriteAt(foo, 4096)
+ _, err = ioutil.ReadFile(fn)
+ if err != nil {
+ t.Error(err)
+ }
+}
+
func BenchmarkStreamWrite(t *testing.B) {
buf := make([]byte, 1024*1024)
t.SetBytes(int64(len(buf)))