Skip to content

Commit eb1486b

Browse files
committed
backend/sdoc_source_code: reader_c: fix a small edge case related to code comments
This is a result of fast coding. Was overlooked that the range was asserted by the itest incorrectly.
1 parent 5de8475 commit eb1486b

File tree

2 files changed

+7
-2
lines changed
  • strictdoc/backend/sdoc_source_code
  • tests/integration/features/test_reports/junit_xml/gtest/05_user_example

2 files changed

+7
-2
lines changed

strictdoc/backend/sdoc_source_code/reader_c.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,14 @@ def read(
261261
function_markers = []
262262
function_comment_node = None
263263
function_comment_text = None
264+
265+
# In the condition below, it is important that the comment is
266+
# considered a function comment only if it there are no empty
267+
# lines between the comment and function.
264268
if (
265269
node_.prev_sibling is not None
266270
and node_.prev_sibling.type == "comment"
271+
and (node_.prev_sibling.end_point[0] + 1) == node_.start_point[0]
267272
):
268273
function_comment_node = node_.prev_sibling
269274
assert function_comment_node.text is not None, node_.text

tests/integration/features/test_reports/junit_xml/gtest/05_user_example/test.itest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN: %check_exists --file "%S/Output/html/_source_files/tests/test1.cpp.html"
1414

1515
# Ensure that the test report document has the right content.
1616
RUN: %cat "%S/Output/html/%THIS_TEST_FOLDER/reports/tests_unit.gtest.junit.html" | filecheck %s --check-prefix CHECK-TEST-REPORT
17-
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestSuiteName.TestName#15#21">
18-
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 15-21</i>, function TEST(MyTestSuiteName, TestName)
17+
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestSuiteName.TestName#17#21">
18+
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 17-21</i>, function TEST(MyTestSuiteName, TestName)
1919
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestHelper.TestName2#32#36">
2020
CHECK-TEST-REPORT: tests/test1.cpp, <i>lines: 32-36</i>, function TEST_F(MyTestHelper, TestName2)
2121
CHECK-TEST-REPORT:href="../../_source_files/tests/test1.cpp.html#MyTestPattern/MyTestHelperPattern.TestName3/1#44#48">

0 commit comments

Comments
 (0)