mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Add dumbindent.Options (tabs vs spaces)
This commit is contained in:
1 parent
53d5f5155c
commit
2858c4cfc2
4 files changed
+54
-15
No files matched your search
@@ -78,12 +78,21 @@ func TestFormatBytes(tt *testing.T) {
|
||||
}}
|
||||
|
||||
for i, tc := range testCases {
|
||||
if got := string(FormatBytes(nil, []byte(tc.src))); got != tc.want {
|
||||
if got := string(FormatBytes(nil, []byte(tc.src), nil)); got != tc.want {
|
||||
tt.Fatalf("i=%d, src=%q:\ngot %q\nwant %q", i, tc.src, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTabs(tt *testing.T) {
|
||||
const src = "a {\nb\n}\n"
|
||||
got := string(FormatBytes(nil, []byte(src), &Options{Tabs: true}))
|
||||
want := "a {\n\tb\n}\n"
|
||||
if got != want {
|
||||
tt.Fatalf("\ngot %q\nwant %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleFormatBytes() {
|
||||
const src = `
|
||||
// Blah blah blah.
|
||||
@@ -95,7 +104,7 @@ if (i < j) { foo(); }
|
||||
}
|
||||
`
|
||||
|
||||
os.Stdout.Write(FormatBytes(nil, []byte(src)))
|
||||
os.Stdout.Write(FormatBytes(nil, []byte(src), nil))
|
||||
|
||||
// Output:
|
||||
// // Blah blah blah.
|
||||
|
||||
Reference in new issue
Block a user