Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(307)

Delta Between Two Patch Sets: src/pkg/net/udp_test.go

Issue 6525048: code review 6525048: net: protocol specific listen functions return a proper... (Closed)
Left Patch Set: diff -r ad0d92901061 https://go.googlecode.com/hg/ Created 11 years, 4 months ago
Right Patch Set: diff -r 0b46d6fe2f1c https://go.googlecode.com/hg/ Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/tcpsock_posix.go ('k') | src/pkg/net/udpsock_plan9.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package net 5 package net
6 6
7 import ( 7 import (
8 "runtime" 8 "runtime"
9 "testing" 9 "testing"
10 ) 10 )
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 _, err = c.WriteTo([]byte("Connection-less mode socket"), ra) 80 _, err = c.WriteTo([]byte("Connection-less mode socket"), ra)
81 if err != nil { 81 if err != nil {
82 t.Fatalf("WriteTo failed: %v", err) 82 t.Fatalf("WriteTo failed: %v", err)
83 } 83 }
84 84
85 _, err = c.(*UDPConn).Write([]byte("Connection-less mode socket")) 85 _, err = c.(*UDPConn).Write([]byte("Connection-less mode socket"))
86 if err == nil { 86 if err == nil {
87 t.Fatal("Write should fail") 87 t.Fatal("Write should fail")
88 } 88 }
89 } 89 }
90
91 var udpConnLocalNameTests = []struct {
92 net string
93 laddr *UDPAddr
94 }{
95 {"udp4", &UDPAddr{IP: IPv4(127, 0, 0, 1)}},
96 {"udp4", &UDPAddr{}},
97 {"udp4", nil},
98 }
99
100 func TestUDPConnLocalName(t *testing.T) {
101 if testing.Short() || !*testExternal {
102 t.Logf("skipping test to avoid external network")
103 return
104 }
105
106 for _, tt := range udpConnLocalNameTests {
107 c, err := ListenUDP(tt.net, tt.laddr)
108 if err != nil {
109 t.Errorf("ListenUDP failed: %v", err)
110 return
111 }
112 defer c.Close()
113 la := c.LocalAddr()
114 if a, ok := la.(*UDPAddr); !ok || a.Port == 0 {
115 t.Errorf("got %v; expected a proper address with non-zer o port number", la)
116 return
117 }
118 }
119 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b