remove deprecated functions and fix corresponding unit test cases

This commit is contained in:
John
2019-09-06 16:59:38 +08:00
parent 0d5dfe59b9
commit 13e528abb6
21 changed files with 57 additions and 57 deletions

View File

@ -104,7 +104,7 @@ func Test_ViolenceCheck(t *testing.T) {
})
}
func Test_GetToVar(t *testing.T) {
func Test_GetVar(t *testing.T) {
data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`)
gtest.Case(t, func() {
var m map[string]string
@ -113,9 +113,9 @@ func Test_GetToVar(t *testing.T) {
j, err := gjson.DecodeToJson(data)
gtest.Assert(err, nil)
j.GetToVar("n", &n)
j.GetToVar("m", &m)
j.GetToVar("a", &a)
j.GetVar("n", &n)
j.GetVar("m", &m)
j.GetVar("a", &a)
gtest.Assert(n, "123456789")
gtest.Assert(m, g.Map{"k": "v"})
@ -340,8 +340,8 @@ func Test_Convert2(t *testing.T) {
gtest.Assert(j.GetJsons("name1"), nil)
gtest.Assert(j.GetJsonMap("name1"), nil)
gtest.Assert(j.Contains("name1"), false)
gtest.Assert(j.GetToVar("name1", &name) == nil, true)
gtest.Assert(j.GetToVar("name", &name) == nil, false)
gtest.Assert(j.GetVar("name1", &name) == nil, true)
gtest.Assert(j.GetVar("name", &name) == nil, false)
gtest.Assert(j.Len("name1"), -1)
gtest.Assert(j.GetTime("time").Format("2006-01-02"), "2019-06-12")
gtest.Assert(j.GetGTime("time").Format("Y-m-d"), "2019-06-12")
@ -354,7 +354,7 @@ func Test_Convert2(t *testing.T) {
gtest.Assert(err, nil)
j = gjson.New(`{"person":{"name":"gf"}}`)
err = j.GetToStruct("person", &name)
err = j.GetStruct("person", &name)
gtest.Assert(err, nil)
gtest.Assert(name.Name, "gf")

View File

@ -30,7 +30,7 @@ func Test_Load_JSON(t *testing.T) {
// JSON
gtest.Case(t, func() {
path := "test.json"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gjson.Load(path)
gtest.Assert(err, nil)
@ -57,7 +57,7 @@ func Test_Load_XML(t *testing.T) {
// XML
gtest.Case(t, func() {
path := "test.xml"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gjson.Load(path)
gtest.Assert(err, nil)
@ -110,7 +110,7 @@ m:
// YAML
gtest.Case(t, func() {
path := "test.yaml"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gjson.Load(path)
gtest.Assert(err, nil)
@ -152,7 +152,7 @@ n = 123456789
// TOML
gtest.Case(t, func() {
path := "test.toml"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gjson.Load(path)
gtest.Assert(err, nil)

View File

@ -86,7 +86,7 @@ func Test_ViolenceCheck(t *testing.T) {
})
}
func Test_GetToVar(t *testing.T) {
func Test_GetVar(t *testing.T) {
data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`)
gtest.Case(t, func() {
var m map[string]string
@ -95,9 +95,9 @@ func Test_GetToVar(t *testing.T) {
j := gparser.New(data)
gtest.AssertNE(j, nil)
j.GetToVar("n", &n)
j.GetToVar("m", &m)
j.GetToVar("a", &a)
j.GetVar("n", &n)
j.GetVar("m", &m)
j.GetVar("a", &a)
gtest.Assert(n, "123456789")
gtest.Assert(m, g.Map{"k": "v"})
@ -233,7 +233,7 @@ func Test_Convert(t *testing.T) {
name := struct {
Name string
}{}
err := p.GetToStruct("person", &name)
err := p.GetStruct("person", &name)
gtest.Assert(err, nil)
gtest.Assert(name.Name, "gf")
gtest.Assert(p.ToMap()["name"], "gf")

View File

@ -31,7 +31,7 @@ func Test_Load_JSON(t *testing.T) {
// JSON
gtest.Case(t, func() {
path := "test.json"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gparser.Load(path)
gtest.Assert(err, nil)
@ -58,7 +58,7 @@ func Test_Load_XML(t *testing.T) {
// XML
gtest.Case(t, func() {
path := "test.xml"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gparser.Load(path)
gtest.Assert(err, nil)
@ -111,7 +111,7 @@ m:
// YAML
gtest.Case(t, func() {
path := "test.yaml"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gparser.Load(path)
gtest.Assert(err, nil)
@ -153,7 +153,7 @@ n = "123456789"
// TOML
gtest.Case(t, func() {
path := "test.toml"
gfile.PutBinContents(path, data)
gfile.PutBytes(path, data)
defer gfile.Remove(path)
j, err := gparser.Load(path)
gtest.Assert(err, nil)