Debian Codegraph @

test/unique_field.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) 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 unique_field.t - Test suite for BibTool unique.field.
31
32 =head1 SYNOPSIS
33
34 unique_field.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 warnings;
55 use BUnit;
56
57 #------------------------------------------------------------------------------
58 BUnit::run(name => 'unique_field_1',
59 resource => <<__EOF__,
60 unique.field {\$key}
61 __EOF__
62 bib => <<__EOF__,
63 \@Manual{BibTool-a,
64 title = {BibTool},
65 author = {Gerd Neugebauer},
66 year = "2019"
67 }
68 \@Manual{BibTool-b,
69 title = {BibTool},
70 author = {Gerd Neugebauer},
71 year = "2019"
72 }
73 \@ARTICLE{article-minimal,
74 author = {L[eslie] A. Aamport},
75 title = {The Gnats and Gnus Document Preparation System},
76 journal = {\\mbox{G-Animal\'s} Journal},
77 year = 1986
78 }
79 __EOF__
80 expected_err => ''
81 );
82
83 #------------------------------------------------------------------------------
84 BUnit::run(name => 'unique_field_10',
85 resource => <<__EOF__,
86 unique.field {\$key}
87 __EOF__
88 bib => <<__EOF__,
89 \@Manual{BibTool,
90 title = {BibTool},
91 author = {Gerd Neugebauer},
92 year = "2019"
93 }
94 \@Manual{BibTool,
95 title = {BibTool},
96 author = {Gerd Neugebauer},
97 year = "2019"
98 }
99 \@ARTICLE{article-minimal,
100 author = {L[eslie] A. Aamport},
101 title = {The Gnats and Gnus Document Preparation System},
102 journal = {\\mbox{G-Animal\'s} Journal},
103 year = 1986
104 }
105 __EOF__
106 expected_err => "*** BibTool WARNING (line 1 in _test.bib) and (line 6 in _test.bib): field `\$key' is not unique: bibtool\n"
107 );
108
109 #------------------------------------------------------------------------------
110 BUnit::run(name => 'unique_field_11',
111 resource => <<__EOF__,
112 unique.field {title}
113 __EOF__
114 bib => <<__EOF__,
115 \@Manual{BibTool,
116 title = {BibTool},
117 author = {Gerd Neugebauer},
118 year = "2019"
119 }
120 \@Manual{BibTool,
121 title = {BibTool},
122 author = {Gerd Neugebauer},
123 year = "2019"
124 }
125 \@ARTICLE{article-minimal,
126 author = {L[eslie] A. Aamport},
127 title = {The Gnats and Gnus Document Preparation System},
128 journal = {\\mbox{G-Animal\'s} Journal},
129 year = 1986
130 }
131
132 __EOF__
133 expected_err => "*** BibTool WARNING (line 1 in _test.bib) and (line 6 in _test.bib): field `title' is not unique: {BibTool}\n"
134 );
135
136 #------------------------------------------------------------------------------
137 BUnit::run(name => 'unique_field_12',
138 resource => <<__EOF__,
139 unique.field {\$sortkey}
140 sort.format{%s(author)}
141 __EOF__
142 bib => <<__EOF__,
143 \@Manual{BibTool,
144 title = {BibTool},
145 author = {Gerd Neugebauer},
146 year = "2019"
147 }
148 \@Manual{BibTool,
149 title = {BibTool},
150 author = {Gerd Neugebauer},
151 year = "2019"
152 }
153 \@ARTICLE{article-minimal,
154 author = {L[eslie] A. Aamport},
155 title = {The Gnats and Gnus Document Preparation System},
156 journal = {\\mbox{G-Animal\'s} Journal},
157 year = 1986
158 }
159 __EOF__
160 expected_err => "*** BibTool WARNING (line 1 in _test.bib) and (line 6 in _test.bib): field `\$sortkey' is not unique: Gerd-Neugebauer\n"
161 );
162
163 #------------------------------------------------------------------------------
164 BUnit::run(name => 'unique_field_13',
165 resource => <<__EOF__,
166 unique.field {\$sortkey}
167 __EOF__
168 bib => <<__EOF__,
169 \@Manual{BibTool,
170 title = {BibTool},
171 author = {Gerd Neugebauer},
172 year = "2019"
173 }
174 \@Manual{BibTool,
175 title = {BibTool},
176 author = {Gerd Neugebauer},
177 year = "2019"
178 }
179 \@ARTICLE{article-minimal,
180 author = {L[eslie] A. Aamport},
181 title = {The Gnats and Gnus Document Preparation System},
182 journal = {\\mbox{G-Animal\'s} Journal},
183 year = 1986
184 }
185 __EOF__
186 expected_err => "*** BibTool WARNING (line 1 in _test.bib) and (line 6 in _test.bib): field `\$sortkey' is not unique: bibtool\n"
187 );
188
189 #------------------------------------------------------------------------------
190 # Local Variables:
191 # mode: perl
192 # End: