File: 07.roundtrip.t

package info (click to toggle)
libdata-ical-perl 0.21%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 388 kB
  • ctags: 247
  • sloc: perl: 3,371; sh: 51; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl -w

use warnings;
use strict;

use Test::More tests => 7;
use Test::LongString;
use Test::NoWarnings; # this catches our warnings like setting unknown properties

BEGIN { use_ok('Data::ICal'); }
BEGIN { use_ok('Data::ICal::Entry::Todo'); }

my $cal = Data::ICal->new();
my $vtodo = Data::ICal::Entry::Todo->new();
$vtodo->add_properties(
    summary   => "Some summary",
    url       => "http://example.com/todo",
    status    => "INCOMPLETE",
);
$cal->add_entry($vtodo);
my $before = $cal->as_string;

$cal = Data::ICal->new( data => $before );
is($cal->as_string, $before, "Round trip works through string");

ok(open(ICS, ">t/ics/roundtrip.ics"), "Wrote t/ics/roundtrip.ics");
print ICS $before;
close ICS;

$cal = Data::ICal->new( filename => "t/ics/roundtrip.ics" );
is($cal->as_string, $before, "Round trip works through file");
ok(unlink("t/ics/roundtrip.ics"), "File t/ics/roundtrip.ics removed");