Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
ee9d148c
Commit
ee9d148c
authored
Feb 13, 2013
by
Mikio Hara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: add test for Dial and Listen arguments
R=dave, bradfitz CC=golang-dev
https://golang.org/cl/7305081
parent
d6331b44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
dial_test.go
src/pkg/net/dial_test.go
+26
-0
No files found.
src/pkg/net/dial_test.go
View file @
ee9d148c
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"fmt"
"fmt"
"io"
"io"
"os"
"os"
"reflect"
"regexp"
"regexp"
"runtime"
"runtime"
"testing"
"testing"
...
@@ -223,6 +224,31 @@ func TestDialError(t *testing.T) {
...
@@ -223,6 +224,31 @@ func TestDialError(t *testing.T) {
}
}
}
}
var
invalidDialAndListenArgTests
=
[]
struct
{
net
string
addr
string
err
error
}{
{
"foo"
,
"bar"
,
&
OpError
{
Op
:
"dial"
,
Net
:
"foo"
,
Addr
:
nil
,
Err
:
UnknownNetworkError
(
"foo"
)}},
{
"baz"
,
""
,
&
OpError
{
Op
:
"listen"
,
Net
:
"baz"
,
Addr
:
nil
,
Err
:
UnknownNetworkError
(
"baz"
)}},
{
"tcp"
,
""
,
&
OpError
{
Op
:
"dial"
,
Net
:
"tcp"
,
Addr
:
nil
,
Err
:
errMissingAddress
}},
}
func
TestInvalidDialAndListenArgs
(
t
*
testing
.
T
)
{
for
_
,
tt
:=
range
invalidDialAndListenArgTests
{
var
err
error
switch
tt
.
err
.
(
*
OpError
)
.
Op
{
case
"dial"
:
_
,
err
=
Dial
(
tt
.
net
,
tt
.
addr
)
case
"listen"
:
_
,
err
=
Listen
(
tt
.
net
,
tt
.
addr
)
}
if
!
reflect
.
DeepEqual
(
tt
.
err
,
err
)
{
t
.
Fatalf
(
"got %#v; expected %#v"
,
err
,
tt
.
err
)
}
}
}
func
TestDialTimeoutFDLeak
(
t
*
testing
.
T
)
{
func
TestDialTimeoutFDLeak
(
t
*
testing
.
T
)
{
if
runtime
.
GOOS
!=
"linux"
{
if
runtime
.
GOOS
!=
"linux"
{
// TODO(bradfitz): test on other platforms
// TODO(bradfitz): test on other platforms
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment