MCPcopy Create free account
hub / github.com/dim-an/cod / TestFindIndentedParagraph

Function TestFindIndentedParagraph

parse_doc/textutil_test.go:43–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestFindIndentedParagraph(t *testing.T) {
44 makeFlattened := func(text, paragraph string) []treeNode {
45 prepared, err := makePreparedText(text)
46 require.NoError(t, err)
47
48 tree := prepared.FindIndentedParagraph(paragraph, 0)
49 require.NotNil(t, tree)
50 return walkLineTree(tree)
51 }
52
53 text := `
54foo bar
55even more foo bar
56
57optional arguments:
58 -h, --help show this help message and exit
59 --version show program's version number and exit
60
61foo bar
62`
63 require.Equal(t,
64 []treeNode{
65 {0, "optional arguments:"},
66 {1, " -h, --help show this help message and exit"},
67 {1, " --version show program's version number and exit"},
68 },
69 makeFlattened(text, "arguments:"))
70
71 text = `
72there comes list:
73 - foo
74 - bar
75 - baz
76 - qux
77`
78
79 require.Equal(t,
80 []treeNode{
81 {0, "there comes list:"},
82 {1, " - foo"},
83 {2, " - bar"},
84 {1, " - baz"},
85 {1, " - qux"},
86 },
87 makeFlattened(text, "list:"))
88
89 text = `
90there comes list:
91 - foo
92 - bar
93
94 - baz
95 - qux
96`
97
98 require.Equal(t,
99 []treeNode{
100 {0, "there comes list:"},

Callers

nothing calls this directly

Calls 3

makePreparedTextFunction · 0.85
walkLineTreeFunction · 0.85
FindIndentedParagraphMethod · 0.80

Tested by

no test coverage detected