mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add random test
This commit is contained in:
parent
42ddbcc3a2
commit
5e6b714836
|
@ -2,6 +2,7 @@ package filesys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,6 +67,29 @@ func TestContinuousIntervals_RealCase1(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRandomWrites(t *testing.T) {
|
||||||
|
|
||||||
|
c := &ContinuousIntervals{}
|
||||||
|
|
||||||
|
data := make([]byte, 1024)
|
||||||
|
|
||||||
|
for i:=0;i<1024;i++ {
|
||||||
|
|
||||||
|
start, stop := rand.Intn(len(data)), rand.Intn(len(data))
|
||||||
|
if start > stop {
|
||||||
|
start,stop = stop, start
|
||||||
|
}
|
||||||
|
|
||||||
|
rand.Read(data[start:stop+1])
|
||||||
|
|
||||||
|
c.AddInterval(data[start:stop+1], int64(start))
|
||||||
|
|
||||||
|
expectedData(t, c, 0, data...)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func expectedData(t *testing.T, c *ContinuousIntervals, offset int, data ...byte) {
|
func expectedData(t *testing.T, c *ContinuousIntervals, offset int, data ...byte) {
|
||||||
start, stop := int64(offset), int64(offset+len(data))
|
start, stop := int64(offset), int64(offset+len(data))
|
||||||
for _, list := range c.lists {
|
for _, list := range c.lists {
|
||||||
|
|
Loading…
Reference in a new issue