#!perl use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use Lingua::EN::Titlecase::HTML; # use Test::More "no_plan"; use Test::More tests => 77; my @test_strings; { my $data = join "", ; for my $test ( split /\n\n/, $data ) { chomp $test; my ( $original, $title, $wc, $mixed ) = split /\n/, $test; $mixed = eval $mixed; push @test_strings, { original => $original, title => $title, wc => $wc, mixedcase => $mixed, }; } } { my $tc = Lingua::EN::Titlecase::HTML->new; for my $testcase ( @test_strings ) { ok( $tc->title($testcase->{original}), "html + Setting original/title string: $testcase->{original}"); is( $tc->original(), $testcase->{original}, "html + Original string returns correctly"); is( $tc->title(), $testcase->{title}, "html + Title(cased)"); is( join(" ", $tc->mixedcase), $testcase->{mixedcase}, "html + Mixedcase counted: $testcase->{title}"); is( scalar($tc->wc), $testcase->{wc}, "html + Wordish (wc) counted: $testcase->{title}"); is( $tc->titlecase, "$tc", "html + Object is quote overloaded"); } # Now repeat tests using new() as raw string setter. for my $testcase ( @test_strings ) { my $tc = Lingua::EN::Titlecase::HTML->new($testcase->{original}); is( $tc->original(), $testcase->{original}, "html + Original string returns correctly"); is( $tc->title(), $testcase->{title}, "html + Title(cased)"); is( join(" ", $tc->mixedcase), $testcase->{mixedcase}, "html + Mixedcase counted: $testcase->{title}"); is( scalar($tc->wc), $testcase->{wc}, "html + Wordish (wc) counted: $testcase->{title}"); is( $tc->titlecase, "$tc", "html + Object is quote overloaded"); } } 1; # TEST DATA FORMAT # Original string # Properly titlecased target string # number found by wc # space joined array of mixedcase letters caught __END__ library Of Perl In between tools Library of Perl in between Tools 6 "" Things That Are Properly Titled Things That Are Properly Titled 5 "" And this with that but the capitalizing cat And This with That but the Capitalizing Cat 8 "" the USA, the USSR with their six-guns to the sky The USA, the USSR with Their Six-guns to the Sky 10 "" U.S. Vs. C.C.C.P. U.S. vs. C.C.C.P. 3 "" 'twas the night before christmas 'Twas the Night before Christmas 5 "" no title for you, triple-threat-hypen and int'l'z'n No Title for You, Triple-threat-hypen and Int'l'z'n 7 ""