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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Test::More;
use BibTeX::Parser::Entry;
sub new_entry {
BibTeX::Parser::Entry->new( 'ARTICLE', 'Foo2010', 1, { @_ } );
}
{
my @german_tests = (
[ '"a' => 'ä' ],
['"`' => '„' ],
["\"'" => '“' ],
);
foreach my $test ( @german_tests ) {
my $entry = new_entry( foo => $test->[0] );
is( $entry->cleaned_field( 'foo', german => 1 ), $test->[1], "Convert $test->[0], german => 1" );
}
}
{
binmode( DATA, ':utf8' );
while (<DATA>) {
chomp;
my ( $tex, $result ) = split /\t/;
is( new_entry( foo => $tex )->cleaned_field( 'foo' ), $result, "Convert $tex" );
}
close DATA;
}
{
my $entry_with_authors = new_entry( author => 'F{\"o}o Bar and B"ar, F.' );
my @authors = $entry_with_authors->author;
is( scalar @authors, 2, "Number of authors is correct");
is( $authors[0]->first, 'F{\"o}o', "non-cleaned version of first" );
is( $authors[0]->last, 'Bar', "non-cleaned version of last" );
is( $authors[1]->first, 'F.', "non-cleaned version of first" );
is( $authors[1]->last, 'B"ar', "non-cleaned version of last" );
my @clean_authors = $entry_with_authors->cleaned_author;
is( $clean_authors[0]->first, 'Föo', "cleaned version of first" );
is( $clean_authors[0]->last, 'Bar', "cleaned version of last" );
is( $clean_authors[1]->first, 'F.', "cleaned version of first" );
is( $clean_authors[1]->last, 'B"ar', "cleaned version of last" );
}
done_testing;
__DATA__
\& &
{\`a} à
{\^a} â
{\~a} ã
{\'a} á
{\'{a}} á
{\"a} ä
{\`A} À
{\'A} Á
{\"A} Ä
{\aa} å
{\AA} Å
{\ae} æ
{\bf 12} 12
{\'c} ć
{\cal P} P
{\c{c}} ç
{\c{C}} Ç
{\c{e}} ȩ
{\c{s}} ş
{\c{S}} Ş
{\c{t}} ţ
{\-d} d
{\`e} è
{\^e} ê
{\'e} é
{\"e} ë
{\'E} É
{\em bits} bits
{\H{o}} ő
{\`i} ì
{\^i} î
{\i} ı
{\`i} ì
{\'i} í
{\"i} ï
{\`\i} ì
{\'\i} í
{\"\i} ï
{\`{\i}} ì
{\'{\i}} í
{\"{\i}} ï
{\it Note} Note
{\k{e}} ę
{\l} ł
{\-l} l
{\log} log
{\~n} ñ
{\'n} ń
{\^o} ô
{\o} ø
{\'o} ó
{\"o} ö
{\"{o}} ö
{\'O} Ó
{\"O} Ö
{\"{O}} Ö
{\rm always} always
{\-s} s
{\'s} ś
{\sc JoiN} JoiN
{\sl bit\/ \bf 7} bit 7
{\sl L'Informatique Nouvelle} L’Informatique Nouvelle
{\small and} and
{\ss} ß
{\TeX} TeX
{\TM} ™
{\tt awk} awk
{\^u} û
{\'u} ú
{\"u} ü
{\"{u}} ü
{\'U} Ú
{\"U} Ü
{\u{a}} ă
{\u{g}} ğ
{\v{c}} č
{\v{C}} Č
{\v{e}} ě
{\v{n}} ň
{\v{r}} ř
{\v{s}} š
{\v{S}} Š
{\v{z}} ž
{\v{Z}} Ž
{\'y} ý
{\.{z}} ż
|