-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathparser_go119_test.go
More file actions
47 lines (33 loc) · 1.3 KB
/
parser_go119_test.go
File metadata and controls
47 lines (33 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
package codescan
import (
"testing"
"github.com/go-openapi/testify/v2/assert"
"github.com/go-openapi/testify/v2/require"
)
func TestSectionedParser_TitleDescriptionGo119(t *testing.T) {
text := `# This has a title that starts with a hash tag
The punctuation here does indeed matter. But it won't for go.
`
text2 := `This has a title without whitespace.
The punctuation here does indeed matter. But it won't for go.
# There is an inline header here that doesn't count for finding a title
`
var err error
st := §ionedParser{}
st.setTitle = func(_ []string) {}
err = st.Parse(ascg(text))
require.NoError(t, err)
assert.Equal(t, []string{"This has a title that starts with a hash tag"}, st.Title())
assert.Equal(t, []string{"The punctuation here does indeed matter. But it won't for go."}, st.Description())
st = §ionedParser{}
st.setTitle = func(_ []string) {}
err = st.Parse(ascg(text2))
require.NoError(t, err)
assert.Equal(t, []string{"This has a title without whitespace."}, st.Title())
assert.Equal(t, []string{
"The punctuation here does indeed matter. But it won't for go.", "",
"# There is an inline header here that doesn't count for finding a title",
}, st.Description())
}