[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [goptlib/master] Increase test coverage.
commit a4cbd4da6b91bc0027e9af52059472090cb1ae69
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Sat Feb 8 20:33:59 2014 -0800
Increase test coverage.
Following the instructions at http://blog.golang.org/cover.
go test -coverprofile=cover.out git.torproject.org/pluggable-transports/goptlib.git
go tool cover -html=cover.out -o cover.html
---
args_test.go | 15 +++++++++++++++
pt_test.go | 15 ++++++++++++---
socks_test.go | 2 ++
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/args_test.go b/args_test.go
index 0a034c0..8a77251 100644
--- a/args_test.go
+++ b/args_test.go
@@ -38,9 +38,17 @@ func TestArgsGet(t *testing.T) {
"b": []string{"value"},
"c": []string{"v1", "v2", "v3"},
}
+ var uninit Args
var v string
var ok bool
+
+ // Get on nil map should be the same as Get on empty map.
+ v, ok = uninit.Get("a")
+ if !(v == "" && !ok) {
+ t.Errorf("unexpected result from Get on nil Args: %q %v", v, ok)
+ }
+
v, ok = args.Get("a")
if ok {
t.Errorf("Unexpected Get success for %q", "a")
@@ -94,6 +102,7 @@ func TestArgsAdd(t *testing.T) {
func TestParseClientParameters(t *testing.T) {
badTests := [...]string{
"key",
+ "key\\",
"=value",
"==value",
"==key=value",
@@ -215,12 +224,14 @@ func optsEqual(a, b map[string]Args) bool {
func TestParseServerTransportOptions(t *testing.T) {
badTests := [...]string{
+ "t\\",
":=",
"t:=",
":k=",
":=v",
"t:=v",
"t:=v",
+ "t:k\\",
"t:k=v;",
"abc",
"t:",
@@ -313,6 +324,10 @@ func TestEncodeSmethodArgs(t *testing.T) {
expected string
}{
{
+ nil,
+ "",
+ },
+ {
Args{},
"",
},
diff --git a/pt_test.go b/pt_test.go
index 7e74f2b..360061c 100644
--- a/pt_test.go
+++ b/pt_test.go
@@ -277,11 +277,12 @@ func TestGetServerBindaddrs(t *testing.T) {
ptServerTransportOptions string
star []string
}{
+ // bad TOR_PT_SERVER_BINDADDR
{
- "xxx",
- "xxx",
+ "alpha",
+ "alpha",
"",
- []string{},
+ []string{"alpha", "beta", "gamma"},
},
{
"alpha-1.2.3.4",
@@ -289,6 +290,14 @@ func TestGetServerBindaddrs(t *testing.T) {
"",
[]string{"alpha", "beta", "gamma"},
},
+ // missing TOR_PT_SERVER_TRANSPORTS
+ {
+ "alpha-1.2.3.4:1111",
+ "",
+ "alpha:key=value",
+ []string{"alpha"},
+ },
+ // bad TOR_PT_SERVER_TRANSPORT_OPTIONS
{
"alpha-1.2.3.4:1111",
"alpha",
diff --git a/socks_test.go b/socks_test.go
index 7f97e9a..18d141a 100644
--- a/socks_test.go
+++ b/socks_test.go
@@ -19,6 +19,8 @@ func TestReadSocks4aConnect(t *testing.T) {
[]byte("\x04\x01\x12\x34\x00\x00\x00\x01key=value\x00hostname"),
// bad nameâ??value mapping
[]byte("\x04\x01\x12\x34\x00\x00\x00\x01userid\x00hostname\x00"),
+ // bad version number
+ []byte("\x03\x01\x12\x34\x01\x02\x03\x04\x00"),
// BIND request
[]byte("\x04\x02\x12\x34\x01\x02\x03\x04\x00"),
// SOCKS5
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits