コード例 #1
0
def test_create_comment_c_multi_contains_ending():
    """Raise CommentCreateError when the text contains a comment ending."""
    text = cleandoc("""
        Hello
        world
        */
        """)

    with pytest.raises(CommentCreateError):
        CCommentStyle.create_comment(text, force_multi=True)
コード例 #2
0
def test_create_comment_c_single():
    """Create a C comment with single-line comments."""
    text = cleandoc("""
        Hello
        world
        """)
    expected = cleandoc("""
        // Hello
        // world
        """)

    assert CCommentStyle.create_comment(text) == expected
コード例 #3
0
def test_create_comment_c_multi_surrounded_by_newlines():
    """Create a C comment that is surrounded by empty lines."""
    text = "\nHello\nworld\n"
    expected = cleandoc("""
        /*
         *
         * Hello
         * world
         *
         */
        """)

    assert CCommentStyle.create_comment(text, force_multi=True) == expected
コード例 #4
0
def test_create_comment_c_multi():
    """Create a C comment with multi-line comments."""
    text = cleandoc("""
        Hello
        world
        """)
    expected = cleandoc("""
        /*
         * Hello
         * world
         */
        """)

    assert CCommentStyle.create_comment(text, force_multi=True) == expected
コード例 #5
0
def test_create_comment_c_multi_empty_newlines():
    """Create a C comment that contains empty lines."""
    text = cleandoc("""
        Hello

        world
        """)
    expected = cleandoc("""
        /*
         * Hello
         *
         * world
         */
        """)

    assert CCommentStyle.create_comment(text, force_multi=True) == expected