Skip to content

Commit 115dc32

Browse files
committed
Fix test.
1 parent 63a3bfe commit 115dc32

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

cppman/formatter/cplusplus.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,40 @@
4545
r'<h1>(.*?)</h1>\s*<div class="C_prototype"[^>]*>'
4646
r'(.*?)</div>\s*<div id="I_description"[^>]*>(.*?)</div>',
4747
r'.TH "\3" 3 "%s" "cplusplus.com" "C++ Programmer\'s Manual"\n'
48-
r'\n.SH NAME\n\3 - \5\n'
49-
r'\n.SE\n.SH TYPE\n\1\n'
50-
r'\n.SE\n.SH SYNOPSIS\n#include \2\n.sp\n\4\n'
51-
r'\n.SE\n.SH DESCRIPTION\n' % datetime.date.today(), re.S),
48+
r'\n.SH "NAME"\n\3 - \5\n'
49+
r'\n.SE\n.SH "TYPE"\n\1\n'
50+
r'\n.SE\n.SH "SYNOPSIS"\n#include \2\n.sp\n\4\n'
51+
r'\n.SE\n.SH "DESCRIPTION"\n' % datetime.date.today(), re.S),
5252
(r'\s*<div id="I_type"[^>]*>(.*?)\s*</div>\s*'
5353
r'<div id="I_file"[^>]*>(.*?)</div>\s*'
5454
r'<h1>(.*?)</h1>\s*'
5555
r'<div id="I_description"[^>]*>(.*?)</div>',
5656
r'.TH "\3" 3 "%s" "cplusplus.com" "C++ Programmer\'s Manual"\n'
57-
r'\n.SH NAME\n\3 - \4\n'
58-
r'\n.SE\n.SH TYPE\n\1\n'
59-
r'\n.SE\n.SH SYNOPSIS\n#include \2\n.sp\n'
60-
r'\n.SE\n.SH DESCRIPTION\n' % datetime.date.today(), re.S),
57+
r'\n.SH "NAME"\n\3 - \4\n'
58+
r'\n.SE\n.SH "TYPE"\n\1\n'
59+
r'\n.SE\n.SH "SYNOPSIS"\n#include \2\n.sp\n'
60+
r'\n.SE\n.SH "DESCRIPTION"\n' % datetime.date.today(), re.S),
6161
(r'\s*<div id="I_type"[^>]*>(.*?)\s*</div>\s*<h1>(.*?)</h1>\s*'
6262
r'<div id="I_description"[^>]*>(.*?)</div>',
6363
r'.TH "\2" 3 "%s" "cplusplus.com" "C++ Programmer\'s Manual"\n'
64-
r'\n.SH NAME\n\2 - \3\n'
65-
r'\n.SE\n.SH TYPE\n\1\n'
66-
r'\n.SE\n.SH DESCRIPTION\n' % datetime.date.today(), re.S),
64+
r'\n.SH "NAME"\n\2 - \3\n'
65+
r'\n.SE\n.SH "TYPE"\n\1\n'
66+
r'\n.SE\n.SH "DESCRIPTION"\n' % datetime.date.today(), re.S),
6767
(r'\s*<div id="I_type"[^>]*>(.*?)\s*</div>\s*<h1>(.*?)</h1>\s*'
6868
r'<div id="I_file"[^>]*>(.*?)</div>\s*<div id="I_description"[^>]*>'
6969
'(.*?)</div>',
7070
r'.TH "\2" 3 "%s" "cplusplus.com" "C++ Programmer\'s Manual"\n'
71-
r'\n.SH NAME\n\2 - \4\n'
72-
r'\n.SE\n.SH TYPE\n\1\n'
73-
r'\n.SE\n.SH DESCRIPTION\n' % datetime.date.today(), re.S),
71+
r'\n.SH "NAME"\n\2 - \4\n'
72+
r'\n.SE\n.SH "TYPE"\n\1\n'
73+
r'\n.SE\n.SH "DESCRIPTION"\n' % datetime.date.today(), re.S),
7474
(r'\s*<div id="I_type"[^>]*>(.*?)\s*</div>\s*<h1>(.*?)</h1>\s*'
7575
r'<div class="C_prototype"[^>]*>(.*?)</div>\s*'
7676
r'<div id="I_description"[^>]*>(.*?)</div>',
7777
r'.TH "\2" 3 "%s" "cplusplus.com" "C++ Programmer\'s Manual"\n'
78-
r'\n.SH NAME\n\2 - \4\n'
79-
r'\n.SE\n.SH TYPE\n\1\n'
80-
r'\n.SE\n.SH SYNOPSIS\n\3\n'
81-
r'\n.SE\n.SH DESCRIPTION\n' % datetime.date.today(), re.S),
78+
r'\n.SH "NAME"\n\2 - \4\n'
79+
r'\n.SE\n.SH "TYPE"\n\1\n'
80+
r'\n.SE\n.SH "SYNOPSIS"\n\3\n'
81+
r'\n.SE\n.SH "DESCRIPTION"\n' % datetime.date.today(), re.S),
8282
(r'<span class="C_ico cpp11warning".*?>', r' [C++11]', re.S),
8383
# Remove empty #include
8484
(r'#include \n.sp\n', r'', 0),
@@ -216,10 +216,10 @@ def html2groff(data, name):
216216
def func_test():
217217
"""Test if there is major format changes in cplusplus.com"""
218218
ifs = urllib.urlopen('http://www.cplusplus.com/printf')
219-
result = html2groff(ifs.read())
220-
assert '.SH NAME' in result
221-
assert '.SH TYPE' in result
222-
assert '.SH DESCRIPTION' in result
219+
result = html2groff(ifs.read(), 'printf')
220+
assert '.SH "NAME"' in result
221+
assert '.SH "TYPE"' in result
222+
assert '.SH "DESCRIPTION"' in result
223223

224224

225225
def test():

cppman/formatter/cppreference.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ def dereference(g):
269269

270270
def func_test():
271271
"""Test if there is major format changes in cplusplus.com"""
272-
ifs = urllib.urlopen('http://www.cplusplus.com/printf')
273-
result = html2groff(ifs.read())
274-
assert '.SH NAME' in result
275-
assert '.SH TYPE' in result
276-
assert '.SH DESCRIPTION' in result
272+
ifs = urllib.urlopen('http://en.cppreference.com/w/cpp/container/vector')
273+
result = html2groff(ifs.read(), 'std::vector')
274+
assert '.SH "NAME"' in result
275+
assert '.SH "SYNOPSIS"' in result
276+
assert '.SH "DESCRIPTION"' in result
277277

278278

279279
def test():

test/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os.path
66
sys.path.insert(0, os.path.normpath(os.getcwd()))
77

8-
from cppman import formatter
8+
from cppman.formatter import cplusplus, cppreference
99

10-
formatter.func_test()
10+
cplusplus.func_test()
11+
cppreference.func_test()

0 commit comments

Comments
 (0)