Skip to content

Commit a14cb3d

Browse files
author
Douglas Jenkins
committed
Added test to fail on invalid port or family values
1 parent 9eafc2c commit a14cb3d

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

S32-io/socket-fail-invalid-values.t

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
use Test;
2+
3+
# RT #130473, #130475
4+
5+
constant HOST = 'localhost';
6+
7+
constant FAMILY_VALUE_TOO_LOW = 1;
8+
constant FAMILY_VALUE_TOO_HIGH = 4;
9+
10+
constant PORT_VALUE_VALID = 5018;
11+
constant PORT_VALUE_TOO_LOW = -1;
12+
constant PORT_VALUE_TOO_HIGH = 65_536;
13+
14+
plan 4;
15+
16+
dies-ok &port-too-low, 'Fails when port is too low';
17+
18+
dies-ok &port-too-high, 'Fails when port is too high';
19+
20+
dies-ok &family-too-low, 'Fails when family is too low';
21+
22+
dies-ok &family-too-high, 'Fails when family is too high';
23+
24+
done-testing;
25+
26+
sub port-too-low() {
27+
my $listen = IO::Socket::INET.new(
28+
:listen,
29+
:localhost(HOST),
30+
:localport(PORT_VALUE_TOO_LOW),
31+
);
32+
}
33+
34+
sub port-too-high() {
35+
my $listen = IO::Socket::INET.new(
36+
:listen,
37+
:localhost(HOST),
38+
:localport(PORT_VALUE_TOO_HIGH),
39+
);
40+
}
41+
42+
sub family-too-low() {
43+
my $listen = IO::Socket::INET.new(
44+
:listen,
45+
:localhost(HOST),
46+
:localport(PORT_VALUE_VALID),
47+
:family(FAMILY_VALUE_TOO_LOW),
48+
);
49+
}
50+
51+
sub family-too-high() {
52+
my $listen = IO::Socket::INET.new(
53+
:listen,
54+
:localhost(HOST),
55+
:localport(PORT_VALUE_VALID),
56+
:family(FAMILY_VALUE_TOO_HIGH),
57+
);
58+
}

0 commit comments

Comments
 (0)