# llil.t # Simple unit test of get_properties() function in LLiL.pm. # Normal run of this test : prove -v -I . llil.t # Can also run with : perl -I . llil.t # Note: before running this test, create the test files # llil-1.txt and llil-2.txt by running: perl create-test-files.pl use strict; use warnings; use LLiL; use Test::More; my $ntests = 5; plan tests => $ntests; my $expected_href = { 'camel' => 69, 'dromedary' => 76, 'kibitzer' => 1000, 'pearl' => 42 }; my %hash_ret; my $href = \%hash_ret; # Error tests { my $n = LLiL::get_properties( 'non-existent-file', $href ); cmp_ok( $n, '==', -1, "get_properties non existent file return value" ); } # Normal tests { my $n = LLiL::get_properties( 'llil-1.txt', $href ); cmp_ok( $n, '==', 3, "get_properties file 1 return value" ); $n = LLiL::get_properties( 'llil-2.txt', $href ); cmp_ok( $n, '==', 5, "get_properties file 2 return value" ); cmp_ok( scalar(%{$href}), '==', 4, "number of items in hash" ); is_deeply( $href, $expected_href, "hash content" ); }