File: Wind.t

package info (click to toggle)
libweather-com-perl 0.5.0-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 340 kB
  • ctags: 148
  • sloc: perl: 3,509; makefile: 44
file content (95 lines) | stat: -rw-r--r-- 3,135 bytes parent folder | download | duplicates (3)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#####################################################################
#
#  Test suite for 'Weather::Com::Wind'
#
#  Before `make install' is performed this script should be runnable
#  with `make test'. After `make install' it should work as
#  `perl t/Wind.t'
#
#####################################################################
#
# initialization
#
no warnings;
use Test::More tests => 25;

BEGIN {
	use_ok('Weather::Com::Wind');
}

#####################################################################
#
# Testing object instantiation (do we use the right class)?
#
my $wind = Weather::Com::Wind->new();
isa_ok( $wind, "Weather::Com::Wind",   'Is a Weatcher::Com::Wind object' );
isa_ok( $wind, "Weather::Com::Object", 'Is a Weatcher::Com::Object object' );

#
# Test negative init when instantiated without arguments
#
is( $wind->speed(),        -1, 'Test negative initialization of speed.' );
is( $wind->maximum_gust(), -1, 'Test negative initialization of speed.' );
is( $wind->direction_degrees(),
	-1, 'Test negative initialization of wind direction.' );
is( $wind->direction_short(),
	'N/A', 'Test negative initialization of wind direction.' );
is( $wind->direction_long(),
	"Not Available",
	'Test negative initialization of wind direction.' );

#
# Test negative init when instantiated for German
#
$wind = Weather::Com::Wind->new( lang => 'de' );
is( $wind->direction_short(),
	'nicht verfgbar',
	'Test negative initialization of wind direction.' );
is( $wind->direction_long(),
	"nicht verfgbar",
	'Test negative initialization of wind direction.' );

#
# Test positive update
#
$wind->update(
			   'gust' => '50',
			   'd'    => '104',
			   's'    => '29',
			   't'    => 'ESE'
);
is( $wind->speed(),             29,           'Test speed update.' );
is( $wind->maximum_gust(),      50,           'Test max gust update.' );
is( $wind->direction_degrees(), 104,          'Test wind direction update.' );
is( $wind->direction_short(),   'OSO',        'Test wind direction update.' );
is( $wind->direction_long(),    "Ost Sdost", 'Test wind direction update.' );

#
# Test positive update
#
$wind->update(
			   'gust' => '50',
			   'd'    => '104',
			   's'    => undef,
			   't'    => 'ESE'
);
is( $wind->speed(),        -1, 'Test negative update of speed.' );
is( $wind->maximum_gust(), -1, 'Test negative update of speed.' );
is( $wind->direction_degrees(),	-1, 'Test negative update of wind direction.' );
is( $wind->direction_short(), 'nicht verfgbar', 'Test negative update of wind direction.' );
is( $wind->direction_long(), "nicht verfgbar", 'Test negative update of wind direction.' );

#
# Test calm update
#
$wind->update(
			   'gust' => '50',
			   'd'    => '104',
			   's'    => 'calm',
			   't'    => 'ESE'
);
is( $wind->speed(),        0, 'Test calm update of speed.' );
is( $wind->maximum_gust(), 0, 'Test calm update of speed.' );
is( $wind->direction_degrees(),	-1, 'Test calm update of wind direction.' );
is( $wind->direction_short(), 'nicht verfgbar', 'Test calm update of wind direction.' );
is( $wind->direction_long(), "nicht verfgbar", 'Test calm update of wind direction.' );