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

Function TestRepairJson

pkg/util/utilfn/partial_test.go:11–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestRepairJson(t *testing.T) {
12 tests := []struct {
13 name string
14 input string
15 expected string
16 }{
17 {
18 name: "open bracket",
19 input: "[",
20 expected: "[]",
21 },
22 {
23 name: "empty array",
24 input: "[]",
25 expected: "[]",
26 },
27 {
28 name: "unclosed string in array",
29 input: `["a`,
30 expected: `["a"]`,
31 },
32 {
33 name: "unclosed array with string",
34 input: `["a"`,
35 expected: `["a"]`,
36 },
37 {
38 name: "unclosed array with number",
39 input: `[5`,
40 expected: `[5]`,
41 },
42 {
43 name: "array with trailing comma",
44 input: `["a",`,
45 expected: `["a"]`,
46 },
47 {
48 name: "array with unclosed second string",
49 input: `["a","`,
50 expected: `["a",""]`,
51 },
52 {
53 name: "unclosed array with string and number",
54 input: `["a",5`,
55 expected: `["a",5]`,
56 },
57 {
58 name: "open brace",
59 input: "{",
60 expected: "{}",
61 },
62 {
63 name: "empty object",
64 input: "{}",
65 expected: "{}",
66 },
67 {
68 name: "unclosed key",

Callers

nothing calls this directly

Calls 2

repairJsonFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected