1use strict; 2use warnings; 3use Data::Dumper; 4 5*qquote= *Data::Dumper::qquote; 6 7sub StoreData 8{ 9 my $hashref = shift ; 10 my $store = shift ; 11 12 my (undef, $file, $line) = caller; 13 ok 1, "StoreData called from $file, line $line"; 14 15 ok ref $store eq 'HASH', "Store Data is a hash reference"; 16 ok tied %$hashref, "Storing to tied hash"; 17 18 while (my ($k, $v) = each %$store) { 19 no warnings 'uninitialized'; 20 #diag "Stored [$k][$v]"; 21 $$hashref{$k} = $v ; 22 } 23 24} 25 26sub VerifyData 27{ 28 my $hashref = shift ; 29 my $expected = shift ; 30 my %expected = %$expected; 31 32 my (undef, $file, $line) = caller; 33 ok 1, "VerifyData called from $file, line $line"; 34 35 ok ref $expected eq 'HASH', "Expected data is a hash reference"; 36 ok tied %$hashref, "Verifying a tied hash"; 37 38 my %bad = (); 39 while (my ($k, $v) = each %$hashref) { 40 no warnings 'uninitialized'; 41 if ($expected{$k} eq $v) { 42 #diag "Match " . qquote($k) . " => " . qquote($v); 43 delete $expected{$k} ; 44 } 45 else { 46 #diag "No Match " . qquote($k) . " => " . qquote($v) . " want " . qquote($expected{$k}); 47 $bad{$k} = $v; 48 } 49 } 50 51 if( ! ok(keys(%bad) + keys(%expected) == 0, "Expected == Actual") ) { 52 my $bad = "Expected does not match actual\n"; 53 if (keys %expected ) { 54 $bad .=" No Match from Expected:\n" ; 55 while (my ($k, $v) = each %expected) { 56 $bad .= "\t" . qquote($k) . " => " . qquote($v) . "\n"; 57 } 58 } 59 if (keys %bad ) { 60 $bad .= "\n No Match from Actual:\n" ; 61 while (my ($k, $v) = each %bad) { 62 no warnings 'uninitialized'; 63 $bad .= "\t" . qquote($k) . " => " . qquote($v) . "\n"; 64 } 65 } 66 diag( "${bad}\n" ); 67 } 68} 69 70 711; 72