File: string_parse.t

package info (click to toggle)
libnet-scp-expect-perl 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 42,328 kB
  • ctags: 17
  • sloc: perl: 438; makefile: 41
file content (122 lines) | stat: -rw-r--r-- 3,053 bytes parent folder | download | duplicates (5)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use strict;
use Test::More qw(no_plan);

BEGIN{ use_ok('Net::SCP::Expect') }

# expected results;
my $xhost1 = "some.host.net";
my $xhost2 = "111.222.333.444";
my $xuser = "some-user";
my $xfile = "~/some_dir/some-file.txt";

my @x1 = ("some-user", "some.host.net", "~/some_dir/some-file.txt");
my @x2 = ("some-user", "some.host.net", "~/some_dir/some-file.txt");

# Everything included
my $scp = Net::SCP::Expect->new(
   host     => $xhost1,
   user     => $xuser,
   password => "bogus",
);

# No host
my $scp2 = Net::SCP::Expect->new(
   user     => $xuser,
   password => "bogus",
);

# No user
my $scp3 = Net::SCP::Expect->new(
   host     => $xhost1,
   password => "bogus",
);

# No host or user
my $scp4 = Net::SCP::Expect->new(
   password => "bogus",
);

my $string1 = '';
my $string2 = ':';
my $string3 = 'some-user@some.host.net:~/some_dir/some-file.txt';
my $string4 = 'some.host.net:~/some_dir/some-file.txt';
my $string5 = ':~/some_dir/some-file.txt';
my $string6 = 'some-user@some.host.net:';
my $string7 = 'some.host.net:';
my $string8 = 'some-user@111.222.333.444:~/some_dir/some-file.txt';
my $string9 = 'some-user@111.222.333.444:';
my $string10 = '111.222.333.444:';
my $string11 = '111.222.333.444:~/some_dir/some-file.txt';

my(@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10,@a11);

# When everything is provided in the constructor
@a1 = $scp->_parse_scp_string($string1);
@a2 = $scp->_parse_scp_string($string2);
@a3 = $scp->_parse_scp_string($string3);
@a4 = $scp->_parse_scp_string($string4);
@a5 = $scp->_parse_scp_string($string5);
@a6 = $scp->_parse_scp_string($string6);
@a7 = $scp->_parse_scp_string($string7);
@a8 = $scp->_parse_scp_string($string8);
@a9 = $scp->_parse_scp_string($string9);
@a10 = $scp->_parse_scp_string($string10);
@a11 = $scp->_parse_scp_string($string11);

is(@a1,@x1);
is(@a2,@x1);
is(@a3,@x1);
is(@a4,@x1);
is(@a5,@x1);
is(@a6,@x1);
is(@a7,@x1);
is(@a8,@x2);
is(@a9,@x2);
is(@a10,@x2);
is(@a11,@x2);

# No host in constructor
@a1 = $scp2->_parse_scp_string($string3);
@a2 = $scp2->_parse_scp_string($string4);
@a3 = $scp2->_parse_scp_string($string6);
@a4 = $scp2->_parse_scp_string($string7);
@a5 = $scp2->_parse_scp_string($string8);
@a6 = $scp2->_parse_scp_string($string9);
@a7 = $scp2->_parse_scp_string($string10);
@a8 = $scp2->_parse_scp_string($string11);

is(@a1,@x1);
is(@a2,@x1);
is(@a3,@x1);
is(@a4,@x1);
is(@a5,@x1);
is(@a6,@x1);
is(@a7,@x1);
is(@a8,@x2);

# No user in constructor
@a1 = $scp3->_parse_scp_string($string1);
@a2 = $scp3->_parse_scp_string($string2);
@a3 = $scp3->_parse_scp_string($string4);
@a4 = $scp3->_parse_scp_string($string5);
@a5 = $scp3->_parse_scp_string($string7);
@a6 = $scp3->_parse_scp_string($string10);
@a7 = $scp3->_parse_scp_string($string11);

is(@a1,@x1);
is(@a1,@x1);
is(@a1,@x1);
is(@a1,@x1);
is(@a1,@x1);
is(@a1,@x1);
is(@a1,@x2);
is(@a1,@x2);

# Neither host nor user in constructor
@a1 = $scp4->_parse_scp_string($string1);
@a2 = $scp4->_parse_scp_string($string2);
@a3 = $scp4->_parse_scp_string($string5);

is(@a1,@x1);
is(@a2,@x1);
is(@a3,@x1);