Skip to content

Commit

Permalink
added a test case for further refactoring purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
maspalio committed Aug 30, 2013
1 parent a80b1a7 commit 05e9a5e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions t/age_string.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env perl

use Test::More;

use Gitprep::Git;

my @cases = (
{ stimulus => 0, expected => ' right now' },
{ stimulus => 1, expected => 'a sec ago' },
{ stimulus => 59, expected => '59 sec ago' },
{ stimulus => 60, expected => 'a min ago' },
{ stimulus => 60 + 1, expected => 'a min ago' },
{ stimulus => 2 * 60 - 1, expected => 'a min ago' },
{ stimulus => 2 * 60, expected => '2 min ago' },
{ stimulus => 2 * 60 + 1, expected => '2 min ago' },
{ stimulus => 60 * 60 - 1, expected => '59 min ago' },
{ stimulus => 60 * 60, expected => 'a hours ago' },
{ stimulus => 60 * 60 + 1, expected => 'a hours ago' },
{ stimulus => 61 * 60, expected => 'a hours ago' },
{ stimulus => 24 * 60 * 60 - 1, expected => '23 hours ago' },
{ stimulus => 24 * 60 * 60, expected => 'a days ago' },
{ stimulus => 24 * 60 * 60 + 1, expected => 'a days ago' },
{ stimulus => 7 * 24 * 60 * 60 - 1, expected => '6 days ago' },
{ stimulus => 7 * 24 * 60 * 60, expected => 'a weeks ago' },
{ stimulus => 7 * 24 * 60 * 60 + 1, expected => 'a weeks ago' },
{ stimulus => (365/12) * 24 * 60 * 60 - 1, expected => '4 weeks ago' },
{ stimulus => (365/12) * 24 * 60 * 60, expected => 'a months ago' },
{ stimulus => (365/12) * 24 * 60 * 60 + 1, expected => 'a months ago' },
{ stimulus => 365 * 24 * 60 * 60 - 1, expected => '11 months ago' },
{ stimulus => 365 * 24 * 60 * 60, expected => 'a years ago' },
{ stimulus => 365 * 24 * 60 * 60 + 1, expected => 'a years ago' },
);

plan ( tests => scalar @cases );

for ( @cases ) {
is ( Gitprep::Git->_age_string ( $_->{stimulus} ), $_->{expected}, "$_->{stimulus} ~ $_->{expected}" );
}

0 comments on commit 05e9a5e

Please sign in to comment.