#!perl -T use warnings; use strict; use File::Spec::Functions; use Test::More; use lib qw( lib ); BEGIN { eval "use XML::Writer"; if ($@) { plan skip_all => "XML::Writer required for testing xml" if $@; } else { plan tests => 62; } } my $datadir = q{data}; # test files my %file2content = (); BEGIN { use_ok('Parse::Flash::Cookie') } use Parse::Flash::Cookie; ok(1); %file2content = ( 'A_Browser.sol' => qr|\s*1\s*\s*|s, 'Synergy_Area.sol' => qr|\s*1\s*\s*|s, 'lastPart.sol' => qr|\s*1\s*\s*|s, 'TestMovie_Config_Info.sol' => qr|\s*\s*1\s*\s*1\s*1\s*1\s*1\s*1\s*\s*\s*1\s*1\s*\s*\s*1\s*1\s*1\s*1\s*0\s*0\s*0\s*1\s*\s*\s*|s, 'clearspring.sol' => qr|\s*470f65bcd2e75653\s*\s*ver=0%2E7%2E8\s*\s*\s*\s*\s*34\s*1192191468014\s*\s*\s*\s*\s*\s*1192191476467\s*\s*\s*1192191466276\s*\s*\s*cs40.clearspring.com:80\s*\s*\s*0\s*\s*\s*0\s*\s*\s*\s*\s*\s*0\s*\s*\s*\s*|s, 'mediaPlayerUserSettings.sol' => qr|\s*1\s*0\s*fit\s*|s, 'revverplayer.sol' => qr|\s*5d72699b80429b5b32e64cbb42ddc73f\s*|s, 'settings.sol' => qr|\s*\s*1\s*1\s*1\s*1\s*1\s*1\s*1\s*1\s*1\s*\s*50\s*0\s*\s*\s*100\s*0\s*0\s*0\s*\s*|s, 'soundData.sol' => qr|\s*100\s*0\s*\s*|s, 'v3_Machine.sol' => qr|\s*100\s*1\s*\s*1\s*159774106279022222\s*1251997\s*1\s*\s*|s, 'v3_PerfComp.sol' => qr|\s*\s*6\s*4\s*5\s*\s*\s*1161599020564\s*1161599713693\s*1161600321118\s*\s*\s*7801549\s*595251\s*1711777\s*\s*\s*1161599715935\s*1161600323067\s*1161602049881\s*\s*1161588196700\s*1161616450212\s*\s*|s, 'v4_UserCredentials.sol' => qr|\s*foo\@bar.com\s*qwerty\s*\s*|s, 'video.sol' => qr|\s*0\s*\s*|s, 'base_test.sol' => qr|\s*inf\s*-inf\s*1\s*0\s*1\s*\s*\s*\s*|s, # expected output from wrong_size.sol equals base_test.sol 'wrong_size.sol' => qr|\s*inf\s*-inf\s*1\s*0\s*1\s*\s*\s*\s*|s, 'pointer.sol' => qr|\s*2\s*\s*inf\s*-inf\s*\s*\s*1\s*0\s*1\s*\s*\s*\s*\s*|s, 'fpv.sol' => qr|\s*\s*\s*\s*|s, 'ivillagee.sol' => qr|\s*\s*1\s*1\s*1\s*1\s*1\s*\s*\s*\s*\s*|s, 'fpv.sol' => qr|\s*\s*\s*|s, 'MFTPMetaGameSo.sol' => qr|\s*10\s*0\s*\s*\s*cookies\s*2\s*\s*\s*rainboot\s*\s*\s*chalk\s*\s*\s*partyhat\s*\s*\s*alarmclock\s*\s*\s*paintbrush\s*\s*\s*pear\s*\s*\s*dogtreat\s*\s*\s*lightbulb\s*\s*\s*bubbleblower\s*\s*\s*letter\s*\s*\s*donut\s*\s*\s*slippers\s*2\s*\s*\s*earmuffs\s*2\s*\s*\s*orange\s*2\s*\s*\s*celery\s*\s*\s*sailboat\s*\s*\s*icecream\s*\s*\s*photo\s*\s*\s*airplane\s*\s*\s*carrotsandwich\s*\s*\s*pencilbox\s*\s*\s*flippers\s*2\s*\s*\s*scooper\s*\s*\s*popcorn\s*\s*\s*lemonade\s*\s*\s*birdhouse\s*\s*\s*mirror\s*\s*\s*beachblanket\s*\s*\s*music\s*hardboiledeggs\s*2\s*2\s*\s*|s, 'p3dagen.sol' => qr|.*\s*|s, ); # Use sort to create test in a predictable sequence foreach my $file (sort keys %file2content) { # untaint using expression from File::Find $file =~ qr|^([-+@\w./]+)$|; $file = $1; # locate test file my $file_with_path = catfile(q{data}, $file); ok(-f $file_with_path, qq{Expect '$file' to be a file on local filesystem}); SKIP: { skip q{Cannot test missing file}, 2 unless -f $file_with_path; # check content of test file my $string = (); eval { $string = Parse::Flash::Cookie::to_xml($file_with_path); }; ok($@ eq q{}, qq{to_xml died when parsing '$file_with_path'}) or diag(q{Error message: } . $@); like ($string, $file2content{$file}, "testing $file_with_path xml content"); } } __END__