aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/dirty_page_interval_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filesys/dirty_page_interval_test.go')
-rw-r--r--weed/filesys/dirty_page_interval_test.go34
1 files changed, 33 insertions, 1 deletions
diff --git a/weed/filesys/dirty_page_interval_test.go b/weed/filesys/dirty_page_interval_test.go
index 4f62f90c9..184be2f3b 100644
--- a/weed/filesys/dirty_page_interval_test.go
+++ b/weed/filesys/dirty_page_interval_test.go
@@ -5,7 +5,7 @@ import (
"testing"
)
-func TestContinuousIntervals_AddInterval(t *testing.T) {
+func TestContinuousIntervals_AddIntervalAppend(t *testing.T) {
c := &ContinuousIntervals{}
@@ -15,6 +15,38 @@ func TestContinuousIntervals_AddInterval(t *testing.T) {
c.AddInterval(getBytes(23, 4), 2)
expectedData(t, c, 0, 25, 25, 23, 23, 23, 23)
+
+}
+
+func TestContinuousIntervals_AddIntervalInnerOverwrite(t *testing.T) {
+
+ c := &ContinuousIntervals{}
+
+ // 25, 25, 25, 25, 25
+ c.AddInterval(getBytes(25, 5), 0)
+ // _, _, 23, 23
+ c.AddInterval(getBytes(23, 2), 2)
+
+ expectedData(t, c, 0, 25, 25, 23, 23, 25)
+
+}
+
+func TestContinuousIntervals_AddIntervalFullOverwrite(t *testing.T) {
+
+ c := &ContinuousIntervals{}
+
+ // 25,
+ c.AddInterval(getBytes(25, 1), 0)
+ // _, _, _, _, 23, 23
+ c.AddInterval(getBytes(23, 2), 4)
+ // _, _, _, 24, 24, 24, 24
+ c.AddInterval(getBytes(24, 4), 3)
+
+ // _, 22, 22
+ c.AddInterval(getBytes(22, 2), 1)
+
+ expectedData(t, c, 0, 25, 22, 22, 24, 24, 24, 24)
+
}
func expectedData(t *testing.T, c *ContinuousIntervals, offset int, data ...byte) {