forked from wendal/goyaml2
-
Notifications
You must be signed in to change notification settings - Fork 5
/
reader_test.go
113 lines (102 loc) · 1.92 KB
/
reader_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package goyaml2
import (
"bytes"
"encoding/json"
"log"
"testing"
)
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
func TestSpileToken(*testing.T) {
strs := []string{"name : wendal",
"skill : [c,c++,java,lua]",
"study: { ppp:123 , vv : 23 }",
"study: { ppp: 123 , vv : 23 }",
"study : { ppp : 123 , vv : 23 } ",
"a:b",
"a:[1,2,3,4,5,6,7,8]"}
for _, str := range strs {
tokens := splitToken(str)
data, _ := json.Marshal(tokens)
log.Println(str, string(data))
}
}
func TestAsMapKeyValue(*testing.T) {
strs := []string{"name : wendal",
"skill : [c,c++,java,lua]",
"study: { ppp:123 , vv : 23 }",
"study: { ppp: 123 , vv : 23 }",
"study : { ppp : 123 , vv : 23 } ",
"a:b",
"a:[1,2,3,4,5,6,7,8]",
"abc : {abc:abc, ccc:zzz,sdfsadfasf:asfasfasfasfasfasfasfasdf}"}
yaml := &yamlReader{}
for _, str := range strs {
key, value, err := yaml.asMapKeyValue(str)
log.Println(key, value, err)
}
}
func TestReadList(*testing.T) {
strs := []string{`
- name
- age
`, `
name : wendal
age : 27
skill : [c, c++, java]
study :
gdut : 2004
jnu : 2008
`, `
tags :
- java
- qq
- golang
catalog :
- Jobs
`, `
---
comments: true
date: 2012-01-06 22:20:11
layout: post
slug: nutdao%e9%85%8d%e7%bd%ae%e5%a4%9a%e6%95%b0%e6%8d%ae%e6%ba%90
title: NutDao配置多数据源
permalink: '/356.html'
wordpress_id: 356
categories:
- Java
tags:
- el
- io
- Nutz
- 连接池
- 配置
---`, `
layout : disqus
disqus :
short_name : wendalblog
livefyre :
site_id : 123
intensedebate :
account : 123abc
facebook :
appid : 123
num_posts: 5
width: 580
colorscheme: light
`, `linenums : false`, `
javascripts:
[processing-1.4.1.min.js]
layout: processing
`, `
javascripts:
[processing-1.4.1.min.js]
layout: processing
`}
for _, str := range strs {
log.Println("!!>>> ", str)
obj, err := Read(bytes.NewBufferString(str))
log.Println("*********", str, obj, err, "*******")
}
}