[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [goptlib/master] Add test for extOrPortSendDone.



commit 58b259d4dfb92fe712375553bf63f28b644f5f03
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Tue Nov 26 23:19:00 2013 -0800

    Add test for extOrPortSendDone.
---
 pt_test.go |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/pt_test.go b/pt_test.go
index cd9c280..5628a96 100644
--- a/pt_test.go
+++ b/pt_test.go
@@ -470,3 +470,22 @@ func TestExtOrSendUserAddr(t *testing.T) {
 		}
 	}
 }
+
+func TestExtOrPortSendDone(t *testing.T) {
+	expected := []byte("\x00\x00\x00\x00")
+
+	var buf bytes.Buffer
+	err := extOrPortSendDone(&buf)
+	if err != nil {
+		t.Errorf("unexpectedly returned an error: %s", err)
+	}
+	p := make([]byte, 1024)
+	n, err := buf.Read(p)
+	if err != nil {
+		t.Fatal(err)
+	}
+	output := p[:n]
+	if !bytes.Equal(output, expected) {
+		t.Errorf("â?? %s (expected %s)", fmtBytes(output), fmtBytes(expected))
+	}
+}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits