MCPcopy
hub / github.com/wavetermdev/waveterm / TestParseMetaValue

Function TestParseMetaValue

cmd/wsh/cmd/setmeta_test.go:136–170  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

134}
135
136func TestParseMetaValue(t *testing.T) {
137 tests := []struct {
138 name string
139 input string
140 want any
141 wantErr bool
142 }{
143 {"empty string", "", nil, false},
144 {"null", "null", nil, false},
145 {"true", "true", true, false},
146 {"false", "false", false, false},
147 {"integer", "42", int64(42), false},
148 {"negative integer", "-42", int64(-42), false},
149 {"hex integer", "0xff", int64(255), false},
150 {"float", "3.14", float64(3.14), false},
151 {"string", "hello", "hello", false},
152 {"json array", "[1,2,3]", []any{float64(1), float64(2), float64(3)}, false},
153 {"json object", `{"foo":"bar"}`, map[string]any{"foo": "bar"}, false},
154 {"quoted string", `"quoted"`, "quoted", false},
155 {"invalid json", `{"invalid`, nil, true},
156 }
157
158 for _, tt := range tests {
159 t.Run(tt.name, func(t *testing.T) {
160 got, err := parseMetaValue(tt.input)
161 if (err != nil) != tt.wantErr {
162 t.Errorf("parseMetaValue() error = %v, wantErr %v", err, tt.wantErr)
163 return
164 }
165 if !tt.wantErr && !reflect.DeepEqual(got, tt.want) {
166 t.Errorf("parseMetaValue() = %v, want %v", got, tt.want)
167 }
168 })
169 }
170}

Callers

nothing calls this directly

Calls 2

parseMetaValueFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected