| 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 |
select_by_string.t - Test suite for BibTool select.by.string. |
| 31 |
|
| 32 |
=head1 SYNOPSIS |
| 33 |
|
| 34 |
select_by_string.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 => 'select_by_string_1', |
| 59 |
args => '--select.by.string=\'{"none"}\' bib/xampl.bib', |
| 60 |
expected_out => <<__EOF__); |
| 61 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 62 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 63 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 64 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 65 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 66 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 67 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 68 |
__EOF__ |
| 69 |
|
| 70 |
#------------------------------------------------------------------------------ |
| 71 |
BUnit::run(name => 'select_by_string_2', |
| 72 |
args => '--select.by.string=\'{"anual-mi"}\' bib/xampl.bib', |
| 73 |
expected_out => <<__EOF__); |
| 74 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 75 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 76 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 77 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 78 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 79 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 80 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 81 |
|
| 82 |
\@Manual{ manual-minimal, |
| 83 |
key = "Manmaker", |
| 84 |
title = "The Definitive Computer Manual" |
| 85 |
} |
| 86 |
__EOF__ |
| 87 |
|
| 88 |
#------------------------------------------------------------------------------ |
| 89 |
BUnit::run(name => 'select_by_string_3', |
| 90 |
args => '--select.by.string=\'{"manmaker"}\' bib/xampl.bib', |
| 91 |
expected_out => <<__EOF__); |
| 92 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 93 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 94 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 95 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 96 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 97 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 98 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 99 |
|
| 100 |
\@Manual{ manual-minimal, |
| 101 |
key = "Manmaker", |
| 102 |
title = "The Definitive Computer Manual" |
| 103 |
} |
| 104 |
|
| 105 |
\@Manual{ manual-full, |
| 106 |
author = "Larry Manmaker", |
| 107 |
title = "The Definitive Computer Manual", |
| 108 |
organization = "Chips-R-Us", |
| 109 |
address = "Silicon Valley", |
| 110 |
edition = "Silver", |
| 111 |
month = apr # "-" # may, |
| 112 |
year = 1986, |
| 113 |
note = "This is a full MANUAL entry" |
| 114 |
} |
| 115 |
__EOF__ |
| 116 |
|
| 117 |
#------------------------------------------------------------------------------ |
| 118 |
BUnit::run(name => 'select_by_string_4', |
| 119 |
args => '--select.by.string=\'{"MISC"}\' bib/xampl.bib', |
| 120 |
expected_out => <<__EOF__); |
| 121 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 122 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 123 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 124 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 125 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 126 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 127 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 128 |
|
| 129 |
\@Misc{ misc-minimal, |
| 130 |
key = "Missilany", |
| 131 |
note = "This is a minimal MISC entry" |
| 132 |
} |
| 133 |
|
| 134 |
\@Misc{ misc-full, |
| 135 |
author = "Joe-Bob Missilany", |
| 136 |
title = "Handing out random pamphlets in airports", |
| 137 |
howpublished = "Handed out at O'Hare", |
| 138 |
month = oct, |
| 139 |
year = 1984, |
| 140 |
note = "This is a full MISC entry" |
| 141 |
} |
| 142 |
__EOF__ |
| 143 |
|
| 144 |
#------------------------------------------------------------------------------ |
| 145 |
BUnit::run(name => 'select_by_string_10', |
| 146 |
args => '--select.by.string=\'{"MISC"}\' bib/xampl.bib', |
| 147 |
expected_out => <<__EOF__); |
| 148 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 149 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 150 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 151 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 152 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 153 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 154 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 155 |
|
| 156 |
\@Misc{ misc-minimal, |
| 157 |
key = "Missilany", |
| 158 |
note = "This is a minimal MISC entry" |
| 159 |
} |
| 160 |
|
| 161 |
\@Misc{ misc-full, |
| 162 |
author = "Joe-Bob Missilany", |
| 163 |
title = "Handing out random pamphlets in airports", |
| 164 |
howpublished = "Handed out at O'Hare", |
| 165 |
month = oct, |
| 166 |
year = 1984, |
| 167 |
note = "This is a full MISC entry" |
| 168 |
} |
| 169 |
__EOF__ |
| 170 |
|
| 171 |
#------------------------------------------------------------------------------ |
| 172 |
BUnit::run(name => 'select_by_string_11', |
| 173 |
args => '--select.by.string=\'{note "Kn"}\' bib/xampl.bib', |
| 174 |
expected_out => <<__EOF__); |
| 175 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 176 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 177 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 178 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 179 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 180 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 181 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 182 |
|
| 183 |
\@Misc{ random-note-crossref, |
| 184 |
key = {Volume-2}, |
| 185 |
note = "Volume~2 is listed under Knuth \\cite{book-full}" |
| 186 |
} |
| 187 |
__EOF__ |
| 188 |
|
| 189 |
#------------------------------------------------------------------------------ |
| 190 |
BUnit::run(name => 'select_by_string_12', |
| 191 |
args => '--select.by.string=\'{$type "misc"}\' bib/xampl.bib', |
| 192 |
expected_out => <<__EOF__); |
| 193 |
\@PREAMBLE{ "\\newcommand{\\noopsort}[1]{} " |
| 194 |
# "\\newcommand{\\printfirst}[2]{#1} " |
| 195 |
# "\\newcommand{\\singleletter}[1]{#1} " |
| 196 |
# "\\newcommand{\\switchargs}[2]{#2#1} " } |
| 197 |
\@STRING{acm = "The OX Association for Computing Machinery" } |
| 198 |
\@STRING{stoc = " Symposium on the Theory of Computing" } |
| 199 |
\@STRING{stoc-key= "OX{\\singleletter{stoc}}" } |
| 200 |
|
| 201 |
\@Misc{ misc-minimal, |
| 202 |
key = "Missilany", |
| 203 |
note = "This is a minimal MISC entry" |
| 204 |
} |
| 205 |
|
| 206 |
\@Misc{ misc-full, |
| 207 |
author = "Joe-Bob Missilany", |
| 208 |
title = "Handing out random pamphlets in airports", |
| 209 |
howpublished = "Handed out at O'Hare", |
| 210 |
month = oct, |
| 211 |
year = 1984, |
| 212 |
note = "This is a full MISC entry" |
| 213 |
} |
| 214 |
|
| 215 |
\@Misc{ random-note-crossref, |
| 216 |
key = {Volume-2}, |
| 217 |
note = "Volume~2 is listed under Knuth \\cite{book-full}" |
| 218 |
} |
| 219 |
__EOF__ |
| 220 |
|
| 221 |
#------------------------------------------------------------------------------ |
| 222 |
#BUnit::run(name => 'select_by_non_string_1', |
| 223 |
# args => '--select.by.non.string=\'{"aa"}\'', |
| 224 |
#expected_err=>'', |
| 225 |
# bib => <<__EOF__, |
| 226 |
#\@article{ a, |
| 227 |
# author = "aa", |
| 228 |
# title = "the title" |
| 229 |
#} |
| 230 |
#\@article{ b, |
| 231 |
# author = "ab", |
| 232 |
# title = "the title" |
| 233 |
#} |
| 234 |
#__EOF__ |
| 235 |
# expected_out => <<__EOF__); |
| 236 |
#__EOF__ |
| 237 |
|
| 238 |
|
| 239 |
1; |
| 240 |
#------------------------------------------------------------------------------ |
| 241 |
# Local Variables: |
| 242 |
# mode: perl |
| 243 |
# End: |