def test_parse_comment_c_multi_misaligned_end(): """Parse a C comment even though the end is misaligned.""" text = cleandoc(""" /* * Hello * world */ """) expected = cleandoc(""" Hello world """) assert CCommentStyle.parse_comment(text) == expected text = cleandoc(""" /* * Hello * world */ """) expected = cleandoc(""" Hello world """) assert CCommentStyle.parse_comment(text) == expected
def test_parse_comment_c_multi_no_start(): """Raise CommentParseError when there is no comment starter.""" text = "Hello world */" with pytest.raises(CommentParseError): CCommentStyle.parse_comment(text) with pytest.raises(CommentParseError): CCommentStyle._parse_comment_multi(text)
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)
def test_comment_at_first_character_c_multi_never_ends(): """Expect CommentParseError if the comment never ends.""" text = cleandoc(""" /* * Hello * world /* """) with pytest.raises(CommentParseError): CCommentStyle.comment_at_first_character(text)
def test_parse_comment_c_multi_text_after_end(): """Raise CommentParseError when there is stuff after the comment delimiter. """ text = cleandoc(""" /* * Hello * world */ Spam """) with pytest.raises(CommentParseError): CCommentStyle.parse_comment(text)
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
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
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
def test_parse_comment_c_multi_starts_at_first(): """Parse a C comment that treats the first line like a regular line.""" text = cleandoc(""" /* Hello * world */ """) expected = cleandoc(""" Hello world """) assert CCommentStyle.parse_comment(text) == expected
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
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
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
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
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
def test_comment_at_first_character_c_multi(): """Simple test for a multi-line C comment.""" text = cleandoc(""" /* * Hello * world */ Spam """) expected = cleandoc(""" /* * Hello * world */ """) assert CCommentStyle.comment_at_first_character(text) == expected
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)
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