-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfiles_test.go
46 lines (38 loc) · 1.1 KB
/
files_test.go
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
package sdf
import (
"fmt"
"testing"
)
func TestFilesFunc(t *testing.T) {
c, d, s := Connect(t)
defer Release(t, c, d, s)
fmt.Println("===SDFGenerateRandom===")
var dataLength uint = 32
randomNum, err := c.SDFGenerateRandom(s, dataLength)
if err != nil {
fmt.Println("generate random error: ", err)
}
fmt.Printf("randomNum: %x randomNumLength: %d \n", randomNum, dataLength)
fmt.Println("===SDFCreateFile===")
err = c.SDFCreateFile(s, []byte("test"), 64)
if err != nil {
fmt.Println("create file error: ", err)
}
fmt.Println("===SDFWriteFile===")
err = c.SDFWriteFile(s, []byte("test"), 0, randomNum, 32)
if err != nil {
fmt.Println("write file error: ", err)
}
fmt.Println("===SDFReadFile===")
var readLength int = len(randomNum)
readbuffer, readLength1, err := c.SDFReadFile(s, []byte("test"), 0, uint(readLength))
if err != nil {
fmt.Println("read file error: ", err)
}
fmt.Printf("readbuffer: %x readLength: %d \n", readbuffer, readLength1)
fmt.Println("===SDFDeleteFile===")
err = c.SDFDeleteFile(s, []byte("test"))
if err != nil {
fmt.Println("delete file error: ", err)
}
}