| 1 | package torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.15 testing/" |
| 5 | |
| 6 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/" |
| 7 | ) |
| 8 | |
| 9 | func TestPartitionStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestPartitionString().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 10 | assert := func(str string, ch byte, expectedA string, expectedB string, expectedOk bool) { |
| 11 | a, b, ok := PartitionStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/PartitionString().(str, ch) |
| 12 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedA, a) |
| 13 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedB, b) |
| 14 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedOk, ok) |
| 15 | } |
| 16 | assert("foo:bar", ':', "foo", "bar", true) |
| 17 | assert(":bar", ':', "", "bar", true) |
| 18 | assert("foo:", ':', "foo", "", true) |
| 19 | assert("foo", ':', "foo", "", false) |
| 20 | assert("foo:bar:baz", ':', "foo", "bar:baz", true) |
| 21 | } |
| 22 | |
| 23 | func TestPartitionStringFromEndscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestPartitionStringFromEnd().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 24 | assert := func(str string, ch byte, expectedA string, expectedB string, expectedOk bool) { |
| 25 | a, b, ok := PartitionStringFromEndscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/PartitionStringFromEnd().(str, ch) |
| 26 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedA, a) |
| 27 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedB, b) |
| 28 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedOk, ok) |
| 29 | } |
| 30 | assert("foo:bar", ':', "foo", "bar", true) |
| 31 | assert(":bar", ':', "", "bar", true) |
| 32 | assert("foo:", ':', "foo", "", true) |
| 33 | assert("foo", ':', "foo", "", false) |
| 34 | assert("foo:bar:baz", ':', "foo:bar", "baz", true) |
| 35 | } |
| 36 | |
| 37 | func TestEscapeSimpleQuotedStringIfNeededscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestEscapeSimpleQuotedStringIfNeeded().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 38 | assert := func(str string, shouldBeDiff bool) { |
| 39 | maybeEscaped := EscapeSimpleQuotedStringIfNeededscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/EscapeSimpleQuotedStringIfNeeded().(str) |
| 40 | if shouldBeDiff { |
| 41 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.NotEqualscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/NotEqual().(t, str, maybeEscaped) |
| 42 | } else { |
| 43 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, str, maybeEscaped) |
| 44 | } |
| 45 | } |
| 46 | assert("foo", false) |
| 47 | assert(" foo", true) |
| 48 | assert("f\\oo", true) |
| 49 | assert("fo\"o", true) |
| 50 | assert("f\roo", true) |
| 51 | assert("fo\no", true) |
| 52 | } |
| 53 | |
| 54 | func TestEscapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestEscapeSimpleQuotedString().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 55 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, "\"foo\"", EscapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/EscapeSimpleQuotedString().("foo")) |
| 56 | } |
| 57 | |
| 58 | func TestEscapeSimpleQuotedStringContentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestEscapeSimpleQuotedStringContents().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 59 | assert := func(str string, expected string) { |
| 60 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expected, EscapeSimpleQuotedStringContentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/EscapeSimpleQuotedStringContents().(str)) |
| 61 | } |
| 62 | assert("foo", "foo") |
| 63 | assert("f\\oo", "f\\\\oo") |
| 64 | assert("f\\noo", "f\\\\noo") |
| 65 | assert("f\n o\ro", "f\\n o\\ro") |
| 66 | assert("fo\r\\\"o", "fo\\r\\\\\\\"o") |
| 67 | } |
| 68 | |
| 69 | func TestUnescapeSimpleQuotedStringIfNeededscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestUnescapeSimpleQuotedStringIfNeeded().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 70 | assert := func(str string, expectedStr string, expectedErr bool) { |
| 71 | actualStr, actualErr := UnescapeSimpleQuotedStringIfNeededscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedStringIfNeeded().(str) |
| 72 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedStr, actualStr) |
| 73 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedErr, actualErr != nil) |
| 74 | } |
| 75 | assert("foo", "foo", false) |
| 76 | assert("\"foo\"", "foo", false) |
| 77 | assert("\"f\"oo\"", "", true) |
| 78 | } |
| 79 | |
| 80 | func TestUnescapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestUnescapeSimpleQuotedString().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 81 | assert := func(str string, expectedStr string, expectedErr bool) { |
| 82 | actualStr, actualErr := UnescapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedString().(str) |
| 83 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedStr, actualStr) |
| 84 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedErr, actualErr != nil) |
| 85 | } |
| 86 | assert("foo", "", true) |
| 87 | assert("\"foo\"", "foo", false) |
| 88 | assert("\"f\"oo\"", "", true) |
| 89 | } |
| 90 | |
| 91 | func TestUnescapeSimpleQuotedStringContentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/TestUnescapeSimpleQuotedStringContents().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 92 | assert := func(str string, expectedStr string, expectedErr bool) { |
| 93 | actualStr, actualErr := UnescapeSimpleQuotedStringContentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedStringContents().(str) |
| 94 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedStr, actualStr) |
| 95 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, expectedErr, actualErr != nil) |
| 96 | } |
| 97 | assert("foo", "foo", false) |
| 98 | assert("f\\\\oo", "f\\oo", false) |
| 99 | assert("f\\\\noo", "f\\noo", false) |
| 100 | assert("f\\n o\\ro", "f\n o\ro", false) |
| 101 | assert("fo\\r\\\\\\\"o", "fo\r\\\"o", false) |
| 102 | assert("f\"oo", "", true) |
| 103 | assert("f\roo", "", true) |
| 104 | assert("f\noo", "", true) |
| 105 | assert("f\\oo", "", true) |
| 106 | } |