unit test

This commit is contained in:
白茶清欢 2022-07-04 18:39:29 +08:00
parent b3740ed1d4
commit 15adffe786
2 changed files with 24 additions and 5 deletions

View File

@ -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
}

View File

@ -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)
}