File: 04.all_day.t

package info (click to toggle)
libdata-ical-datetime-perl 0.82-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 308 kB
  • sloc: perl: 1,708; makefile: 2; sh: 1
file content (69 lines) | stat: -rw-r--r-- 2,017 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use strict;


use Test::More tests => 24;


use Data::ICal::DateTime;
use Data::ICal::Entry::Event;
use DateTime;
use DateTime::Set;
use DateTime::TimeZone;

my $cal;
ok($cal = Data::ICal->new( filename => 't/ics/all_day.ics'), "parse all_day ics");


my $date1 = DateTime->new( year => 2005, month => 8, day => 1, hour => 23, minute => 59, second => 59 );
my $date2 = DateTime->new( year => 2005, month => 10, day => 27, hour => 23, minute => 59, second => 59);

my @events = $cal->events;
is (@events, 2, "2 total events");
my ($e1, $e2) = @events;

is ($e1->summary,"Event 1");
is ($e2->summary,"Event 2");

is("".$e1->end, "".$date1, "E1's end is the correct date");
is("".$e2->end, "".$date1, "E2's end is the correct date");
is($e1->all_day,0,   "E1 is not all day");
is($e2->all_day,1,   "E2 is all day");

$e1->end($date2);
$e2->end($date2);

is("".$e1->end, "".$date2, "E1's end is the correct new date");
is("".$e2->end, "".$date2, "E2's end is the correct new date");
is($e1->all_day, 0,  "E1 is not all day");
is($e2->all_day, 1,  "E2 is all day");

$e2->all_day(0);
is($e2->all_day, 0,  "E2 is not all day");
is("".$e2->end, "".$date2, "E2's end is the correct new date");
$e2->all_day(1);
is($e2->all_day, 1,  "E2 is now all day again ");
is("".$e2->end, "".$date2, "E2's end is the correct new date");
	
$e1->end($date1);
$e2->end($date1);

my @e1 = $e1->split_up('hour');
my @e2 = $e2->split_up('hour');

is(@e1, 14, "e1 14 exploded");
is(@e2, 14, "e2 14 exploded");
is($e1[0]->all_day, 0, "e1 exploded is not all day");
is($e2[0]->all_day, 0, "e2 exploded is all day");
is($e1[0]->original->all_day, 0, "e1 exploded wasn't originally all day");
is($e2[0]->original->all_day, 1, "e2 exploded was originally all day");


# test setting all day without end 
my $new = Data::ICal::Entry::Event->new();

my $new_date = $date1->clone->truncate( to => 'day' );
$new->start($new_date);
$new->all_day(1);

is ($new->all_day, 1, "New is all day");
is ("".$new->end, "".$date1, "New end is the same as start");