Debian Codegraph @

test/check_warning_rule.t

raw
1 #!/usr/bin/env perl
2 # =============================================================================
3 #
4 # This file is part of BibTool.
5 # It is distributed under the GNU General Public License.
6 # See the file COPYING for details.
7 #
8 # (c) 2011-2020 Gerd Neugebauer
9 #
10 # Net: [email protected]
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
15 # any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #
26 #*=============================================================================
27
28 =head1 NAME
29
30 check_warning_rule.t - Test suite for BibTool check.warning.rule.
31
32 =head1 SYNOPSIS
33
34 check_warning_rule.t
35
36 =head1 DESCRIPTION
37
38 This module contains some test cases. Running this module as program
39 will run all test cases and print a summary for each. Optionally files
40 *.out and *.err are left if the expected result does not match the
41 actual result.
42
43 =head1 OPTIONS
44
45 none
46
47 =head1 AUTHOR
48
49 Gerd Neugebauer
50
51 =cut
52
53 use strict;
54 use BUnit;use warnings;
55
56
57 #------------------------------------------------------------------------------
58 BUnit::run(name => 'check_warning_rule_1',
59 resource => <<__EOF__,
60 check.warning.rule { year "^[\\"{]1[89][0-9][0-9][\\"}]\$" }
61 check.warning.rule { year "^[\\"{][0-9][0-9][\\"}]\$" }
62 check.warning.rule { year "" "\\@ \\\$: Year has to be a suitable number"}
63 __EOF__
64 bib => <<__EOF__,
65 \@Manual{BibTool,
66 title = {BibTool},
67 author = {Gerd Neugebauer},
68 year = "2011"
69 }
70 __EOF__
71 expected_err => "*** BibTool WARNING (line 1 in _test.bib): Manual bibtool: Year has to be a suitable number\n"
72 );
73
74 #------------------------------------------------------------------------------
75 BUnit::run(name => 'check_warning_rule_2',
76 resource => <<__EOF__,
77 check.warning.rule { year "^[\\"{]1[89][0-9][0-9][\\"}]\$" }
78 check.warning.rule { year "^[\\"{][0-9][0-9][\\"}]\$" }
79 check.warning.rule { year "" "\\@ \\\$: Year has to be a suitable number"}
80 __EOF__
81 bib => <<__EOF__,
82 \@Manual{BibTool,
83 title = {BibTool},
84 author = {Gerd Neugebauer},
85 year = "1987"
86 }
87 __EOF__
88 expected_err => ''
89 );
90
91 #------------------------------------------------------------------------------
92 BUnit::run(name => 'check_warning_rule_3',
93 resource => <<__EOF__,
94 check.warning.rule { year "^[\\"{]1[89][0-9][0-9][\\"}]\$" }
95 check.warning.rule { year "^[\\"{][0-9][0-9][\\"}]\$" }
96 check.warning.rule { year "" "\\@ \\\$: Year has to be a suitable number"}
97 __EOF__
98 bib => <<__EOF__,
99 \@Manual{BibTool,
100 title = {BibTool},
101 author = {Gerd Neugebauer},
102 year = "xxx"
103 }
104 __EOF__
105 expected_err => "*** BibTool WARNING (line 1 in _test.bib): Manual bibtool: Year has to be a suitable number\n"
106 );
107
108 #------------------------------------------------------------------------------
109 BUnit::run(name => 'check_warning_rule_4',
110 resource => <<__EOF__,
111 check.warning.rule { year "^[\\"{]20[0-9][0-9][\\"}]\$" }
112 check.warning.rule { year "^[\\"{][0-9][0-9][\\"}]\$" }
113 check.warning.rule { year "" "\\@ \\\$: Year has to be a suitable number"}
114 __EOF__
115 bib => <<__EOF__,
116
117
118 \@Manual{BibTool,
119 title = {BibTool},
120 author = {Gerd Neugebauer},
121 year = "xxx"
122 }
123 __EOF__
124 expected_err => "*** BibTool WARNING (line 3 in _test.bib): Manual bibtool: Year has to be a suitable number\n"
125 );
126
127 #------------------------------------------------------------------------------
128 BUnit::run(name => 'check_warning_rule_5',
129 stdin => 1,
130 resource => <<__EOF__,
131 check.warning.rule { year "^[\\"{]20[0-9][0-9][\\"}]\$" }
132 check.warning.rule { year "^[\\"{][0-9][0-9][\\"}]\$" }
133 check.warning.rule { year "" "\\@ \\\$: Year has to be a suitable number"}
134 __EOF__
135 bib => <<__EOF__,
136
137
138 \@Manual{BibTool,
139 title = {BibTool},
140 author = {Gerd Neugebauer},
141 year = "xxx"
142 }
143 __EOF__
144 expected_err => "*** BibTool WARNING (line 3 in <STDIN>): Manual bibtool: Year has to be a suitable number\n"
145 );
146
147 #------------------------------------------------------------------------------
148 BUnit::run(name => 'check_warning_rule_6',
149 stdin => 1,
150 resource => <<__EOF__,
151 sort = true
152 check.warning.rule { year "^[\\"{]20[0-9][0-9][\\"}]\$" }
153 check.warning.rule { year "^[\\"{][0-9][0-9][\\"}]\$" }
154 check.warning.rule { year "" "\\@ \\\$: Year has to be a suitable number"}
155 __EOF__
156 bib => <<__EOF__,
157
158
159 \@Manual{BibTool,
160 title = {BibTool},
161 author = {Gerd Neugebauer},
162 year = "xxx"
163 }
164 __EOF__
165 expected_err => "*** BibTool WARNING (line 3 in <STDIN>): Manual bibtool: Year has to be a suitable number\n"
166 );
167
168 #------------------------------------------------------------------------------
169 # Local Variables:
170 # mode: perl
171 # End: