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

Side by Side Diff: src/pkg/net/net_test.go

Issue 5593046: code review 5593046: net: replace error variable name e, errno with err (Closed)
Patch Set: diff -r 05b67fff4f9c https://go.googlecode.com/hg/ Created 13 years, 1 month 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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/net/multicast_test.go ('k') | src/pkg/net/sendfile_linux.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 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 "flag" 8 "flag"
9 "io" 9 "io"
10 "regexp" 10 "regexp"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 var duplicateErrorPattern = `dial (.*) dial (.*)` 66 var duplicateErrorPattern = `dial (.*) dial (.*)`
67 67
68 func TestDialError(t *testing.T) { 68 func TestDialError(t *testing.T) {
69 if !*runErrorTest { 69 if !*runErrorTest {
70 t.Logf("test disabled; use --run_error_test to enable") 70 t.Logf("test disabled; use --run_error_test to enable")
71 return 71 return
72 } 72 }
73 for i, tt := range dialErrorTests { 73 for i, tt := range dialErrorTests {
74 » » c, e := Dial(tt.Net, tt.Raddr) 74 » » c, err := Dial(tt.Net, tt.Raddr)
75 if c != nil { 75 if c != nil {
76 c.Close() 76 c.Close()
77 } 77 }
78 » » if e == nil { 78 » » if err == nil {
79 t.Errorf("#%d: nil error, want match for %#q", i, tt.Pat tern) 79 t.Errorf("#%d: nil error, want match for %#q", i, tt.Pat tern)
80 continue 80 continue
81 } 81 }
82 » » s := e.Error() 82 » » s := err.Error()
83 match, _ := regexp.MatchString(tt.Pattern, s) 83 match, _ := regexp.MatchString(tt.Pattern, s)
84 if !match { 84 if !match {
85 t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern ) 85 t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern )
86 } 86 }
87 match, _ = regexp.MatchString(duplicateErrorPattern, s) 87 match, _ = regexp.MatchString(duplicateErrorPattern, s)
88 if match { 88 if match {
89 t.Errorf("#%d: %q, duplicate error return from Dial", i, s) 89 t.Errorf("#%d: %q, duplicate error return from Dial", i, s)
90 } 90 }
91 } 91 }
92 } 92 }
(...skipping 11 matching lines...) Expand all
104 {"1234:567::89a:bcde", "e.d.c.b.a.9.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 7.6.5.0.4.3.2.1.ip6.arpa.", ""}, 104 {"1234:567::89a:bcde", "e.d.c.b.a.9.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0. 7.6.5.0.4.3.2.1.ip6.arpa.", ""},
105 {"1234:567:fefe:bcbc:adad:9e4a:89a:bcde", "e.d.c.b.a.9.8.0.a.4.e.9.d.a.d .a.c.b.c.b.e.f.e.f.7.6.5.0.4.3.2.1.ip6.arpa.", ""}, 105 {"1234:567:fefe:bcbc:adad:9e4a:89a:bcde", "e.d.c.b.a.9.8.0.a.4.e.9.d.a.d .a.c.b.c.b.e.f.e.f.7.6.5.0.4.3.2.1.ip6.arpa.", ""},
106 {"1.2.3", "", "unrecognized address"}, 106 {"1.2.3", "", "unrecognized address"},
107 {"1.2.3.4.5", "", "unrecognized address"}, 107 {"1.2.3.4.5", "", "unrecognized address"},
108 {"1234:567:bcbca::89a:bcde", "", "unrecognized address"}, 108 {"1234:567:bcbca::89a:bcde", "", "unrecognized address"},
109 {"1234:567::bcbc:adad::89a:bcde", "", "unrecognized address"}, 109 {"1234:567::bcbc:adad::89a:bcde", "", "unrecognized address"},
110 } 110 }
111 111
112 func TestReverseAddress(t *testing.T) { 112 func TestReverseAddress(t *testing.T) {
113 for i, tt := range revAddrTests { 113 for i, tt := range revAddrTests {
114 » » a, e := reverseaddr(tt.Addr) 114 » » a, err := reverseaddr(tt.Addr)
115 » » if len(tt.ErrPrefix) > 0 && e == nil { 115 » » if len(tt.ErrPrefix) > 0 && err == nil {
116 t.Errorf("#%d: expected %q, got <nil> (error)", i, tt.Er rPrefix) 116 t.Errorf("#%d: expected %q, got <nil> (error)", i, tt.Er rPrefix)
117 continue 117 continue
118 } 118 }
119 » » if len(tt.ErrPrefix) == 0 && e != nil { 119 » » if len(tt.ErrPrefix) == 0 && err != nil {
120 » » » t.Errorf("#%d: expected <nil>, got %q (error)", i, e) 120 » » » t.Errorf("#%d: expected <nil>, got %q (error)", i, err)
121 } 121 }
122 » » if e != nil && e.(*DNSError).Err != tt.ErrPrefix { 122 » » if err != nil && err.(*DNSError).Err != tt.ErrPrefix {
123 » » » t.Errorf("#%d: expected %q, got %q (mismatched error)", i, tt.ErrPrefix, e.(*DNSError).Err) 123 » » » t.Errorf("#%d: expected %q, got %q (mismatched error)", i, tt.ErrPrefix, err.(*DNSError).Err)
124 } 124 }
125 if a != tt.Reverse { 125 if a != tt.Reverse {
126 t.Errorf("#%d: expected %q, got %q (reverse address)", i , tt.Reverse, a) 126 t.Errorf("#%d: expected %q, got %q (reverse address)", i , tt.Reverse, a)
127 } 127 }
128 } 128 }
129 } 129 }
130 130
131 func TestShutdown(t *testing.T) { 131 func TestShutdown(t *testing.T) {
132 if runtime.GOOS == "plan9" { 132 if runtime.GOOS == "plan9" {
133 return 133 return
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 var buf [10]byte 166 var buf [10]byte
167 n, err := c.Read(buf[:]) 167 n, err := c.Read(buf[:])
168 if err != nil { 168 if err != nil {
169 t.Fatalf("client Read: %d, %v", n, err) 169 t.Fatalf("client Read: %d, %v", n, err)
170 } 170 }
171 got := string(buf[:n]) 171 got := string(buf[:n])
172 if got != "response" { 172 if got != "response" {
173 t.Errorf("read = %q, want \"response\"", got) 173 t.Errorf("read = %q, want \"response\"", got)
174 } 174 }
175 } 175 }
OLDNEW
« no previous file with comments | « src/pkg/net/multicast_test.go ('k') | src/pkg/net/sendfile_linux.go » ('j') | no next file with comments »

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