[BACK]Return to md5.t CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo-REST-API / t / formats

Annotation of todotxt/Text-Todo-REST-API/t/formats/md5.t, Revision 1.5

1.1       andrew      1: #===============================================================================
                      2: #
                      3: #         FILE:  md5.t
                      4: #
1.5     ! andrew      5: #  DESCRIPTION:  Test Text::Todo::REST::API::Representations::md5
1.1       andrew      6: #
                      7: #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
                      8: #      COMPANY:  Red River Communications
                      9: #      CREATED:  01/07/10 19:11
1.5     ! andrew     10: #     REVISION:  $AFresh1: md5.t,v 1.4 2010/01/19 03:18:34 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
1.5     ! andrew     16: use Test::More tests => 17;
1.1       andrew     17:
                     18: my $class;
1.5     ! andrew     19: my $format;
1.1       andrew     20:
                     21: BEGIN {
1.5     ! andrew     22:     $format = 'md5';
        !            23:     $class  = 'Text::Todo::REST::API::Representations::' . $format;
1.1       andrew     24:     use_ok( $class, "use $class" );
                     25: }
                     26:
1.5     ! andrew     27: diag(
        !            28:     "Testing entry $class $Text::Todo::REST::API::Representations::md5::VERSION"
        !            29: );
        !            30:
        !            31: my $result;
        !            32: my $api = new_ok($class);
1.1       andrew     33:
1.5     ! andrew     34: is( $api->content_type, 'text/plain', 'Check content_type' );
1.1       andrew     35:
1.5     ! andrew     36: my $list = [
1.1       andrew     37:     {   'text' => '(A) entry 1 @one +uno',
                     38:         'md5'  => '931e0831c31a70928b29de55778dc294',
                     39:         'line' => 1
                     40:     },
                     41:     {   'text' => 'entry 2 @two +dos',
                     42:         'md5'  => 'b38dde8029c047e81379d9de581a6251',
                     43:         'line' => 2
                     44:     },
                     45:     {   'text' => '',
                     46:         'md5'  => 'd41d8cd98f00b204e9800998ecf8427e',
                     47:         'line' => 3
                     48:     },
                     49:     {   'text' => 'x completed entry 4',
                     50:         'md5'  => '8de0a2b65a50d5e30e84ad48af46fa78',
                     51:         'line' => 4
                     52:     },
                     53:     {   'text' => '(B) entry 5 is priority',
                     54:         'md5'  => 'c1692dfbf3b5829b6bce44b1a1614980',
                     55:         'line' => 5
                     56:     },
                     57:     {   'text' => 'entry 6 +delete',
                     58:         'md5'  => 'e1f6bf867f75aa019063782554407d02',
                     59:         'line' => 6
                     60:     }
                     61: ];
                     62:
1.5     ! andrew     63: my $list_render = join q{},
        !            64:     map { 'MD5 (' . $_->{text} . ') = ' . $_->{md5} . "\n" } @{$list};
1.1       andrew     65:
                     66: $result = undef;
1.5     ! andrew     67: ok( $result = $api->render_list( $format, $list ), 'render_list' );
        !            68: is( $result, $list_render, 'List rendered properly' );
1.1       andrew     69:
1.5     ! andrew     70: foreach my $e ( @{$list} ) {
1.1       andrew     71:     my $result;
1.5     ! andrew     72:     ok( eval { $result = $api->render_entry( $format, $e ) },
        !            73:         'render_entry' );
1.1       andrew     74:     is( $result,
                     75:         'MD5 (' . $e->{text} . ') = ' . $e->{md5} . "\n",
1.5     ! andrew     76:         'entry rendered properly'
1.1       andrew     77:     );
                     78: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>