Beispiel #1
0
def test_parse_comment_c_multi_ends_at_last():
    """Parse a C comment that treats the last line like a regular line."""
    text = cleandoc("""
        /*
         * Hello
         * world */
        """)
    expected = cleandoc("""
        Hello
        world
        """)

    assert CCommentStyle.parse_comment(text) == expected
Beispiel #2
0
def test_parse_comment_c_multi():
    """Parse a C comment with multi-line comments."""
    text = cleandoc("""
        /*
         * Hello
         * world
         */
        """)
    expected = cleandoc("""
        Hello
        world
        """)
    assert CCommentStyle.parse_comment(text) == expected
Beispiel #3
0
def test_parse_comment_c_multi_indented():
    """Preserve indentations in C comments."""
    text = cleandoc("""
        /*
         * Hello
         *   world
         */
        """)
    expected = cleandoc("""
        Hello
          world
        """)

    assert CCommentStyle.parse_comment(text) == expected
Beispiel #4
0
def test_parse_comment_c_multi_missing_middle():
    """Parse a C comment even though the middle markers are missing."""
    text = cleandoc("""
        /*
        Hello
        world
        */
        """)
    expected = cleandoc("""
        Hello
        world
        """)

    assert CCommentStyle.parse_comment(text) == expected
Beispiel #5
0
def test_parse_comment_c_multi_no_middle():
    """Parse a C comment that has no middle whatsoever."""
    text = cleandoc(
        """
        /* Hello
         * world */
        """
    )
    expected = cleandoc(
        """
        Hello
        world
        """
    )

    assert CCommentStyle.parse_comment(text) == expected
Beispiel #6
0
def test_parse_comment_c_single():
    """Parse a C comment with single-line comments."""
    text = cleandoc(
        """
        // Hello
        // world
        """
    )
    expected = cleandoc(
        """
        Hello
        world
        """
    )

    assert CCommentStyle.parse_comment(text) == expected
Beispiel #7
0
def test_parse_comment_c_multi_no_end():
    """Raise CommentParseError when there is no comment end."""
    text = "/* Hello world"

    with pytest.raises(CommentParseError):
        CCommentStyle.parse_comment(text)
Beispiel #8
0
def test_parse_comment_c_multi_single_line():
    """Parse a single-line multi-line comment."""
    text = "/* Hello world */"
    expected = "Hello world"

    assert CCommentStyle.parse_comment(text) == expected