MCPcopy Index your code
hub / github.com/go-python/gopy / TestPrinter

Function TestPrinter

bind/printer_test.go:14–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestPrinter(t *testing.T) {
15 decl := &printer{
16 buf: new(bytes.Buffer),
17 indentEach: []byte("\t"),
18 }
19
20 impl := &printer{
21 buf: new(bytes.Buffer),
22 indentEach: []byte("\t"),
23 }
24
25 decl.Printf("\ndecl 1\n")
26 decl.Indent()
27 decl.Printf(">>> decl-1\n")
28 decl.Outdent()
29 impl.Printf("impl 1\n")
30 decl.Printf("decl 2\n")
31 impl.Printf("impl 2\n")
32
33 out := new(bytes.Buffer)
34 _, err := io.Copy(out, decl)
35 if err != nil {
36 t.Fatalf("error: %v\n", err)
37 }
38
39 _, err = io.Copy(out, impl)
40 if err != nil {
41 t.Fatalf("error: %v\n", err)
42 }
43
44 want := `
45decl 1
46 >>> decl-1
47decl 2
48impl 1
49impl 2
50`
51
52 str := out.String()
53 if !reflect.DeepEqual(str, want) {
54 t.Fatalf("error:\nwant=%q\ngot =%q\n", want, str)
55 }
56
57}

Callers

nothing calls this directly

Calls 4

PrintfMethod · 0.95
IndentMethod · 0.95
OutdentMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected