unit test
This commit is contained in:
parent
b3740ed1d4
commit
15adffe786
@ -8,8 +8,9 @@
|
||||
package filter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/util"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -20,6 +21,7 @@ import (
|
||||
//
|
||||
// Date : 18:11 2022/7/4
|
||||
func parseLexical(jsonData string) ([]lexicalNode, error) {
|
||||
jsonData = strings.ReplaceAll(strings.ReplaceAll(jsonData, "\n", ""), "\t", "")
|
||||
if len(jsonData) < 2 {
|
||||
return nil, errors.New("input data is not json")
|
||||
}
|
||||
@ -48,8 +50,7 @@ func parseLexical(jsonData string) ([]lexicalNode, error) {
|
||||
tmpStr = tmpStr + currentChar
|
||||
}
|
||||
}
|
||||
byteData, _ := json.Marshal(lexicalList)
|
||||
fmt.Println("============ : ", string(byteData))
|
||||
util.JSON.ConsoleOutput(lexicalList)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -12,5 +12,23 @@ import (
|
||||
)
|
||||
|
||||
func Test_parseLexical(t *testing.T) {
|
||||
parseLexical("{iiiiiiiii}")
|
||||
jsonData := `{
|
||||
"name":"zhangsan",
|
||||
"age":"18",
|
||||
"extension":{
|
||||
"sex":"man",
|
||||
"height":"180"
|
||||
},
|
||||
"teacher_list":[
|
||||
{
|
||||
"name":"t1",
|
||||
"age":"11"
|
||||
},
|
||||
{
|
||||
"name":"t2",
|
||||
"age":"12"
|
||||
}
|
||||
]
|
||||
}`
|
||||
parseLexical(jsonData)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user