-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcomments_tests.py
More file actions
37 lines (31 loc) · 1.67 KB
/
comments_tests.py
File metadata and controls
37 lines (31 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
# -*- coding: utf-8
"""Unit tests for code in comments.py."""
from comments import comment_string_with_inline, \
comment_string_with_block, \
comment_string
import unittest
class TestCommentString(unittest.TestCase):
"""Unit tests related to string commenting"""
def test_inline_comment(self):
"""Unit tests related to inline comments"""
self.assertEqual(comment_string_with_inline('', None), '')
self.assertEqual(comment_string_with_inline('', '#'), '')
self.assertEqual(comment_string_with_inline('a', '#'), '# a\n')
self.assertEqual(comment_string_with_inline('a\nb', '#'), '# a\n# b\n')
def test_block_comment(self):
"""Unit tests related to block comments"""
self.assertEqual(comment_string_with_block('', None), '')
self.assertEqual(comment_string_with_block('', ('/*', '*/')), '')
self.assertEqual(comment_string_with_block('a', ('/*', '*/')), '/* a */')
self.assertEqual(comment_string_with_block('a\nb', ('/*', '*/')), '/* a\nb */')
def test_comment(self):
"""Unit tests related to inline comments"""
self.assertEqual(comment_string('', None, None), '')
self.assertEqual(comment_string('a', None, None), '')
self.assertEqual(comment_string('a', '#', None), '# a\n')
self.assertEqual(comment_string('a', None, ('/*', '*/')), '/* a */')
self.assertEqual(comment_string('a', '#', ('/*', '*/')), '# a\n')
self.assertEqual(comment_string('a\nb', '#', None), '# a\n# b\n')
self.assertEqual(comment_string('a\nb', '#', ('/*', '*/')), '/* a\nb */')
# vim: filetype=python tabstop=8 expandtab shiftwidth=4 softtabstop=4