[tor-commits] [goptlib/master] Factor out a tcpAddrsEqual function.

dcf at torproject.org dcf at torproject.org
Thu Nov 14 07:00:22 UTC 2013


commit 639435bcb76bd026143dcd019d9af878b338bac2
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Nov 13 22:34:42 2013 -0800

    Factor out a tcpAddrsEqual function.
---
 pt_test.go |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pt_test.go b/pt_test.go
index 86a38dc..ff3373d 100644
--- a/pt_test.go
+++ b/pt_test.go
@@ -105,6 +105,10 @@ func stringSetsEqual(a, b []string) bool {
 	return true
 }
 
+func tcpAddrsEqual(a, b *net.TCPAddr) bool {
+	return a.IP.Equal(b.IP) && a.Port == b.Port
+}
+
 func TestGetClientTransports(t *testing.T) {
 	tests := [...]struct {
 		ptServerClientTransports string
@@ -211,7 +215,7 @@ func TestResolveAddr(t *testing.T) {
 		if err != nil {
 			t.Errorf("%q unexpectedly returned an error: %s", test.input, err)
 		}
-		if !output.IP.Equal(test.expected.IP) || output.Port != test.expected.Port {
+		if !tcpAddrsEqual(output, &test.expected) {
 			t.Errorf("%q → %q (expected %q)", test.input, output, test.expected)
 		}
 	}





More information about the tor-commits mailing list