File: 03usage.t

package info (click to toggle)
libtext-vfile-asdata-perl 0.08-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 292 kB
  • sloc: perl: 771; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,301 bytes parent folder | download | duplicates (4)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
use strict;
use warnings;

use Test::More;

# Show an example of API in use, and test it at the same time

use Text::vFile::asData;
my $data = Text::vFile::asData->new->parse(\*DATA);

is(ref $data, 'HASH', 'Got back a hash ref');

# Should have one VCALENDAR object
is(scalar @{ $data->{objects} }, 1, 'Found one object');
is($data->{objects}->[0]->{type}, 'VCALENDAR', '  and it\'s a VCALENDAR');

# Get all the properties of this object.  There should be two (the other
# properties in there, DTSTART, etc, belong to the VEVENT object
my @properties = keys %{ $data->{objects}->[0]->{properties} };
is(scalar @properties, 2, 'Got 2 properties, as expected');

is($data->{objects}->[0]->{properties}->{'VERSION'}->[0]->{value}, '2.0',
   'VERSION is 2.0');
is($data->{objects}->[0]->{properties}->{'PRODID'}->[0]->{value},
   '-//hacksw/handcal//NONSGML v1.0//EN', 'PRODID looks right');

# Get the event info
my $e = $data->{objects}->[0]->{objects}->[0];
is($e->{type}, 'VEVENT', 'First sub object is a VEVENT');

done_testing();

#  Local Variables:
#  cperl-indent-level: 4
#  End:

__DATA__

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR