Adding upstream version 1.2.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
6a5b4a9666
commit
82a6c39bcf
24 changed files with 2727 additions and 0 deletions
44
wrapio/wrapio_test.go
Normal file
44
wrapio/wrapio_test.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package wrapio
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWrapper(t *testing.T) {
|
||||
if file, err := ioutil.TempFile("", "wrap.test"); err == nil {
|
||||
defer os.Remove(file.Name())
|
||||
defer file.Close()
|
||||
file.Write([]byte("abcdef"))
|
||||
|
||||
data := make([]byte, 12)
|
||||
|
||||
w := NewWrapper(file, 6, 1, 6)
|
||||
if n, err := w.ReadAt(data, 1); err == nil || err == io.EOF {
|
||||
if !bytes.Equal(data[:n], []byte("cdefa")) {
|
||||
t.Errorf("Exp cdefa, Got %s", data[:n])
|
||||
}
|
||||
} else {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrap(t *testing.T) {
|
||||
if file, err := ioutil.TempFile("", "wrap.test"); err == nil {
|
||||
w := NewWrapWriter(file, 0, 3)
|
||||
w.Write([]byte("abcdef"))
|
||||
|
||||
r := NewWrapReader(file, 0, 2)
|
||||
data := make([]byte, 6)
|
||||
r.Read(data)
|
||||
if !bytes.Equal(data, []byte("dedede")) {
|
||||
t.Error("Wrapper error!")
|
||||
}
|
||||
file.Close()
|
||||
os.Remove(file.Name())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue