Skip to content

Commit

Permalink
More lcm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 8, 2021
1 parent 034eea5 commit 74c0559
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions t/lcm.t
Expand Up @@ -10,7 +10,7 @@ LCM: {
if($@) {
plan(skip_all => 'Locale::Country::Multilingual required for this test');
} else {
plan(tests => 13);
plan(tests => 18);

use_ok('Test::NoWarnings');
use_ok('Class::Simple::Readonly::Cached');
Expand All @@ -27,6 +27,13 @@ LCM: {
is($lcm->code2country('US'), 'United States', 'Second call to United States');
is($lcm->code2country('US', 'fr_FR'), 'États-Unis', 'Fourth call to États-Unis');

$lcm->set_lang('fr');
is($lcm->country2code('Angleterre'), undef, 'Angleterre returns undef');
is($lcm->country2code('Angleterre'), undef, 'Second call to Angleterre returns undef');
is($lcm->country2code('England'), undef, 'England returns undef');
is($lcm->country2code('Angleterre'), undef, 'Third call to Angleterre returns undef');
is($lcm->country2code('England'), undef, 'Third call to England returns undef');

if($ENV{'TEST_VERBOSE'}) {
foreach my $key($cache->get_keys()) {
diag($key);
Expand All @@ -39,13 +46,13 @@ LCM: {
while(my($k, $v) = each %{$hits}) {
$count += $v;
}
is($count, 4, 'cache contains 4 hits');
is($count, 7, 'cache contains 7 hits');

my $misses = $lcm->state()->{'misses'};
$count = 0;
while(my($k, $v) = each %{$misses}) {
$count += $v;
}
is($count, 2, 'cache contains 2 misses');
is($count, 5, 'cache contains 5 misses');
}
}

0 comments on commit 74c0559

Please sign in to comment.