Skip to content

Commit ab08e21

Browse files
committed
Remove Indent/Compact
Signed-off-by: Jonathan Rudenberg <[email protected]>
1 parent 533559c commit ab08e21

File tree

2 files changed

+0
-225
lines changed

2 files changed

+0
-225
lines changed

indent.go

Lines changed: 0 additions & 141 deletions
This file was deleted.

scanner_test.go

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
package json5
66

77
import (
8-
"bytes"
98
"math"
109
"math/rand"
11-
"reflect"
1210
"testing"
1311
)
1412

@@ -43,88 +41,6 @@ var ex1i = `[
4341
-5e+2
4442
]`
4543

46-
func TestCompact(t *testing.T) {
47-
var buf bytes.Buffer
48-
for _, tt := range examples {
49-
buf.Reset()
50-
if err := Compact(&buf, []byte(tt.compact)); err != nil {
51-
t.Errorf("Compact(%#q): %v", tt.compact, err)
52-
} else if s := buf.String(); s != tt.compact {
53-
t.Errorf("Compact(%#q) = %#q, want original", tt.compact, s)
54-
}
55-
56-
buf.Reset()
57-
if err := Compact(&buf, []byte(tt.indent)); err != nil {
58-
t.Errorf("Compact(%#q): %v", tt.indent, err)
59-
continue
60-
} else if s := buf.String(); s != tt.compact {
61-
t.Errorf("Compact(%#q) = %#q, want %#q", tt.indent, s, tt.compact)
62-
}
63-
}
64-
}
65-
66-
func TestCompactSeparators(t *testing.T) {
67-
// U+2028 and U+2029 should be escaped inside strings.
68-
// They should not appear outside strings.
69-
tests := []struct {
70-
in, compact string
71-
}{
72-
{"{\"\u2028\": 1}", `{"\u2028":1}`},
73-
{"{\"\u2029\" :2}", `{"\u2029":2}`},
74-
}
75-
for _, tt := range tests {
76-
var buf bytes.Buffer
77-
if err := Compact(&buf, []byte(tt.in)); err != nil {
78-
t.Errorf("Compact(%q): %v", tt.in, err)
79-
} else if s := buf.String(); s != tt.compact {
80-
t.Errorf("Compact(%q) = %q, want %q", tt.in, s, tt.compact)
81-
}
82-
}
83-
}
84-
85-
func TestIndent(t *testing.T) {
86-
var buf bytes.Buffer
87-
for _, tt := range examples {
88-
buf.Reset()
89-
if err := Indent(&buf, []byte(tt.indent), "", "\t"); err != nil {
90-
t.Errorf("Indent(%#q): %v", tt.indent, err)
91-
} else if s := buf.String(); s != tt.indent {
92-
t.Errorf("Indent(%#q) = %#q, want original", tt.indent, s)
93-
}
94-
95-
buf.Reset()
96-
if err := Indent(&buf, []byte(tt.compact), "", "\t"); err != nil {
97-
t.Errorf("Indent(%#q): %v", tt.compact, err)
98-
continue
99-
} else if s := buf.String(); s != tt.indent {
100-
t.Errorf("Indent(%#q) = %#q, want %#q", tt.compact, s, tt.indent)
101-
}
102-
}
103-
}
104-
105-
type indentErrorTest struct {
106-
in string
107-
err error
108-
}
109-
110-
var indentErrorTests = []indentErrorTest{
111-
{`{"X": "foo", "Y"}`, &SyntaxError{"invalid character '}' after object key", 17}},
112-
{`{"X": "foo" "Y": "bar"}`, &SyntaxError{"invalid character '\"' after object key:value pair", 13}},
113-
}
114-
115-
func TestIndentErrors(t *testing.T) {
116-
for i, tt := range indentErrorTests {
117-
slice := make([]uint8, 0)
118-
buf := bytes.NewBuffer(slice)
119-
if err := Indent(buf, []uint8(tt.in), "", ""); err != nil {
120-
if !reflect.DeepEqual(err, tt.err) {
121-
t.Errorf("#%d: Indent: %#v", i, err)
122-
continue
123-
}
124-
}
125-
}
126-
}
127-
12844
func diff(t *testing.T, a, b []byte) {
12945
for i := 0; ; i++ {
13046
if i >= len(a) || i >= len(b) || a[i] != b[i] {

0 commit comments

Comments
 (0)