"Fossies" - the Fresh Open Source Software Archive

Member "email-reminder-0.8.1/t/roundtrip.t" (14 Mar 2015, 1269 Bytes) of package /linux/privat/email-reminder-0.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 use File::Temp;
    7 use Test::More tests => 16;
    8 
    9 use EmailReminder::EventList;
   10 use EmailReminder::Event;
   11 
   12 # load the data in
   13 my $er_orig = EmailReminder::EventList->new('t/data.xml', 1);
   14 
   15 # save it out again
   16 my (undef, $tmp_file) = File::Temp::tempfile();
   17 $er_orig->save(0, $tmp_file);
   18 
   19 # load it back and compare all elements
   20 my $er_new = EmailReminder::EventList->new($tmp_file, 1);
   21 
   22 # compare top level info
   23 is($er_orig->_get_user_fname, $er_new->_get_user_fname, 'fname');
   24 is($er_orig->_get_user_lname, $er_new->_get_user_lname, 'lname');
   25 is($er_orig->get_user_email, $er_new->get_user_email, 'email');
   26 
   27 # compare all the events and make sure they are the same too
   28 my @events_orig = $er_orig->get_events();
   29 my @events_new = $er_new->get_events();
   30 
   31 is(scalar @events_orig, scalar @events_new, "same number of events");
   32 
   33 for ( my $i = 0; $i < @events_orig; $i++ ) {
   34     my $orig_event = $events_orig[$i] . "";
   35     for ( my $j = 0; $j < @events_new; $j++ ) {
   36         my $new_event = $events_new[$j] . "";
   37         if ($orig_event eq $new_event) {
   38             is($orig_event, $new_event, "event $i");
   39             splice (@events_new, $j, 1);
   40             last;
   41         }
   42     }
   43 }
   44 is(scalar @events_new, 0, "all events were found");