MCPcopy Index your code
hub / github.com/bootdotdev/bootdev / TestExtractTmdlBlock

Function TestExtractTmdlBlock

checks/tmdl_test.go:5–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestExtractTmdlBlock(t *testing.T) {
6 input := "root\n child one\n grandchild\n\n child two\nnext root"
7
8 tests := []struct {
9 name string
10 query string
11 want string
12 }{
13 {
14 name: "blank query returns input",
15 query: " ",
16 want: input,
17 },
18 {
19 name: "missing query returns empty string",
20 query: "missing",
21 want: "",
22 },
23 {
24 name: "extracts matching item block",
25 query: "child one",
26 want: " child one\n grandchild",
27 },
28 {
29 name: "blank lines do not terminate block",
30 query: "root",
31 want: "root\n child one\n grandchild\n\n child two",
32 },
33 }
34
35 for _, tt := range tests {
36 t.Run(tt.name, func(t *testing.T) {
37 got := ExtractTmdlBlock(input, tt.query)
38 if got != tt.want {
39 t.Fatalf("ExtractTmdlBlock() = %q, want %q", got, tt.want)
40 }
41 })
42 }
43}
44
45func TestExtractTmdlBlockHandlesTabIndentation(t *testing.T) {
46 input := "item\n\tchild\n\t\tgrandchild\n\tsibling\nnext"

Callers

nothing calls this directly

Calls 1

ExtractTmdlBlockFunction · 0.85

Tested by

no test coverage detected