MCPcopy
hub / github.com/MadAppGang/dingo / TestFormatterBasic

Function TestFormatterBasic

pkg/format/formatter_test.go:8–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestFormatterBasic(t *testing.T) {
9 tests := []struct {
10 name string
11 input string
12 want string
13 }{
14 {
15 name: "simple_assignment",
16 input: `package main
17let x=42`,
18 want: `package main
19let x = 42
20`,
21 },
22 {
23 name: "function_call",
24 input: `fmt.Println(x,y,z)`,
25 want: `fmt.Println(x, y, z)
26`,
27 },
28 {
29 name: "comment_preservation",
30 input: `// This is a comment
31let x=42`,
32 want: `// This is a comment
33let x = 42
34`,
35 },
36 }
37
38 f := New(DefaultConfig())
39
40 for _, tt := range tests {
41 t.Run(tt.name, func(t *testing.T) {
42 got, err := f.Format([]byte(tt.input))
43 if err != nil {
44 t.Fatalf("Format() error = %v", err)
45 }
46
47 gotStr := string(got)
48 if gotStr != tt.want {
49 t.Errorf("Format() mismatch:\nInput:\n%s\nGot:\n%s\nWant:\n%s",
50 tt.input, gotStr, tt.want)
51 }
52 })
53 }
54}
55
56func TestMatchFormatting(t *testing.T) {
57 tests := []struct {

Callers

nothing calls this directly

Calls 6

NewFunction · 0.70
DefaultConfigFunction · 0.70
RunMethod · 0.65
FormatMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected