2525 "end_column" : 17 ,
2626 },
2727 ),
28+ # Test case for leading space after start sequence (bug fix)
29+ (
30+ f"@ title 1, IMPL_1 { UNIX_NEWLINE } " ,
31+ {
32+ "title" : "title 1" ,
33+ "id" : "IMPL_1" ,
34+ "type" : "impl" ,
35+ "links" : [],
36+ "start_column" : 1 ,
37+ "end_column" : 18 ,
38+ },
39+ ),
40+ # Test case for multiple leading spaces after start sequence
41+ (
42+ f"@ title 1, IMPL_1 { UNIX_NEWLINE } " ,
43+ {
44+ "title" : "title 1" ,
45+ "id" : "IMPL_1" ,
46+ "type" : "impl" ,
47+ "links" : [],
48+ "start_column" : 1 ,
49+ "end_column" : 20 ,
50+ },
51+ ),
52+ # Test case for trailing space before end sequence
53+ (
54+ f"@title 1, IMPL_1 { UNIX_NEWLINE } " ,
55+ {
56+ "title" : "title 1" ,
57+ "id" : "IMPL_1" ,
58+ "type" : "impl" ,
59+ "links" : [],
60+ "start_column" : 1 ,
61+ "end_column" : 18 ,
62+ },
63+ ),
64+ # Test case for both leading and trailing spaces
65+ (
66+ f"@ title 1, IMPL_1 { UNIX_NEWLINE } " ,
67+ {
68+ "title" : "title 1" ,
69+ "id" : "IMPL_1" ,
70+ "type" : "impl" ,
71+ "links" : [],
72+ "start_column" : 1 ,
73+ "end_column" : 21 ,
74+ },
75+ ),
2876 ],
2977)
3078def test_oneline_parser_default_config_positive (
@@ -34,6 +82,99 @@ def test_oneline_parser_default_config_positive(
3482 assert oneline_need == result
3583
3684
85+ # Test case for space as field separator (as mentioned by Kilian)
86+ # Example: @Implementation <field1> <field2>
87+ ONELINE_COMMENT_STYLE_SPACE_SEPARATOR = OneLineCommentStyle (
88+ start_sequence = "@" ,
89+ end_sequence = UNIX_NEWLINE ,
90+ field_split_char = " " ,
91+ needs_fields = [
92+ {"name" : "title" },
93+ {"name" : "id" },
94+ {"name" : "type" , "default" : "impl" },
95+ ],
96+ )
97+
98+
99+ @pytest .mark .parametrize (
100+ "oneline, result" ,
101+ [
102+ # Basic space-separated fields
103+ (
104+ f"@Implementation IMPL_1{ UNIX_NEWLINE } " ,
105+ {
106+ "title" : "Implementation" ,
107+ "id" : "IMPL_1" ,
108+ "type" : "impl" ,
109+ "start_column" : 1 ,
110+ "end_column" : 22 ,
111+ },
112+ ),
113+ # Space separator with explicit type
114+ (
115+ f"@MyFeature FEAT_001 feature{ UNIX_NEWLINE } " ,
116+ {
117+ "title" : "MyFeature" ,
118+ "id" : "FEAT_001" ,
119+ "type" : "feature" ,
120+ "start_column" : 1 ,
121+ "end_column" : 27 ,
122+ },
123+ ),
124+ # Leading space after @ (the bug Kilian reported)
125+ (
126+ f"@ Implementation IMPL_2{ UNIX_NEWLINE } " ,
127+ {
128+ "title" : "Implementation" ,
129+ "id" : "IMPL_2" ,
130+ "type" : "impl" ,
131+ "start_column" : 1 ,
132+ "end_column" : 23 ,
133+ },
134+ ),
135+ # Trailing space before newline
136+ (
137+ f"@Implementation IMPL_3 { UNIX_NEWLINE } " ,
138+ {
139+ "title" : "Implementation" ,
140+ "id" : "IMPL_3" ,
141+ "type" : "impl" ,
142+ "start_column" : 1 ,
143+ "end_column" : 23 ,
144+ },
145+ ),
146+ # Multiple leading spaces after @
147+ (
148+ f"@ Title ID_456{ UNIX_NEWLINE } " ,
149+ {
150+ "title" : "Title" ,
151+ "id" : "ID_456" ,
152+ "type" : "impl" ,
153+ "start_column" : 1 ,
154+ "end_column" : 15 ,
155+ },
156+ ),
157+ # Title contain spaces
158+ (
159+ f"@ Title\ escape\ space ID_456{ UNIX_NEWLINE } " ,
160+ {
161+ "title" : "Title escape space" ,
162+ "id" : "ID_456" ,
163+ "type" : "impl" ,
164+ "start_column" : 1 ,
165+ "end_column" : 30 ,
166+ },
167+ ),
168+ ],
169+ )
170+ def test_oneline_parser_space_separator (
171+ oneline : str , result : dict [str , str | list [str ]]
172+ ) -> None :
173+ """Test oneline parser with space as field separator."""
174+ oneline_need = oneline_parser (oneline , ONELINE_COMMENT_STYLE_SPACE_SEPARATOR )
175+ assert oneline_need == result
176+
177+
37178@pytest .mark .parametrize (
38179 "oneline, result" ,
39180 [
0 commit comments