-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonfs_test.go
38 lines (34 loc) · 873 Bytes
/
jsonfs_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
package jsonfs
import (
"fmt"
"testing"
)
const (
dataStr = `{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}`
)
func TestNamev(t *testing.T) {
fsys, _ := NewFS([]byte(dataStr))
fmt.Println(fsys.namev(""))
fmt.Println(fsys.namev("."))
fmt.Println(fsys.namev("menu/id/ok"))
fmt.Println(fsys.namev("menu/popup/menuitem/2/onclick"))
fmt.Println(fsys.namev("menu/popup/menuitem/3/value"))
}
func TestReadDir(t *testing.T) {
fsys, _ := NewFS([]byte(dataStr))
fmt.Println(fsys.ReadDir(""))
fmt.Println(fsys.ReadDir("."))
fmt.Println(fsys.ReadDir("menu"))
fmt.Println(fsys.ReadDir("menu/popup/menuitem/2/onclick"))
fmt.Println(fsys.ReadDir("menu/popup/menuitem/3"))
}