MCPcopy Create free account
hub / github.com/campoy/embedmd / TestParser

Function TestParser

embedmd/parser_test.go:24–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestParser(t *testing.T) {
25 tc := []struct {
26 name string
27 in string
28 out string
29 run commandRunner
30 err string
31 }{
32 {
33 name: "empty file",
34 in: "",
35 out: "",
36 },
37 {
38 name: "just text",
39 in: "one\ntwo\nthree\n",
40 out: "one\ntwo\nthree\n",
41 },
42 {
43 name: "a command",
44 in: "one\n[embedmd]:# (code.go)",
45 out: "one\n[embedmd]:# (code.go)\nOK\n",
46 run: func(w io.Writer, cmd *command) error {
47 if cmd.path != "code.go" {
48 return fmt.Errorf("bad command")
49 }
50 fmt.Fprint(w, "OK\n")
51 return nil
52 },
53 },
54 {
55 name: "a command then some text",
56 in: "one\n[embedmd]:# (code.go)\nYay\n",
57 out: "one\n[embedmd]:# (code.go)\nOK\nYay\n",
58 run: func(w io.Writer, cmd *command) error {
59 if cmd.path != "code.go" {
60 return fmt.Errorf("bad command")
61 }
62 fmt.Fprint(w, "OK\n")
63 return nil
64 },
65 },
66 {
67 name: "a bad command",
68 in: "one\n[embedmd]:# (code\n",
69 err: "2: argument list should be in parenthesis",
70 },
71 {
72 name: "an ignored command",
73 in: "one\n```\n[embedmd]:# (code.go)\n```\n",
74 out: "one\n```\n[embedmd]:# (code.go)\n```\n",
75 },
76 {
77 name: "unbalanced code section",
78 in: "one\n```\nsome code\n",
79 err: "3: unbalanced code section",
80 },
81 {

Callers

nothing calls this directly

Calls 2

processFunction · 0.85
eqErrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…