MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestGetMap

Function TestGetMap

internal/utils/get_test.go:51–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestGetMap(t *testing.T) {
52 object := map[string]interface{}{
53 "Name": "lu",
54 "Age": 20,
55 "Extend": map[string]interface{}{
56 "Location": map[string]interface{}{
57 "City": "Beijing",
58 },
59 },
60 }
61
62 if Get(object, []string{"Name"}) != "lu" {
63 t.Fatal("[ERROR]Name != lu")
64 }
65
66 if Get(object, []string{"Age"}) != 20 {
67 t.Fatal("[ERROR]Age != 20")
68 }
69
70 if Get(object, []string{"Books", "0"}) != nil {
71 t.Fatal("[ERROR]books.0 != nil")
72 }
73
74 t.Log(Get(object, []string{"Extend", "Location"}))
75
76 if Get(object, []string{"Extend", "Location", "City"}) != "Beijing" {
77 t.Fatal("[ERROR]Extend.Location.City != Beijing")
78 }
79}

Callers

nothing calls this directly

Calls 2

GetFunction · 0.85
LogMethod · 0.80

Tested by

no test coverage detected