summaryrefslogtreecommitdiff
path: root/vendor/github.com/getlantern/hidden/hidden_test.go
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2019-01-12 18:39:45 +0100
committerRuben Pollan <meskio@sindominio.net>2019-01-17 12:30:32 +0100
commitb1247d2d0d51108c910a73891ff3116e5f032ab1 (patch)
treee9948964f0bfb1ad2df3bc7bad02aa1f41ccfbd8 /vendor/github.com/getlantern/hidden/hidden_test.go
parentefcb8312e31b5c2261b1a1e95ace55b322cfcc27 (diff)
[pkg] all your deps are vendored to us
Diffstat (limited to 'vendor/github.com/getlantern/hidden/hidden_test.go')
-rw-r--r--vendor/github.com/getlantern/hidden/hidden_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/github.com/getlantern/hidden/hidden_test.go b/vendor/github.com/getlantern/hidden/hidden_test.go
new file mode 100644
index 0000000..420ce64
--- /dev/null
+++ b/vendor/github.com/getlantern/hidden/hidden_test.go
@@ -0,0 +1,33 @@
+package hidden
+
+import (
+ "encoding/binary"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestRoundTrip(t *testing.T) {
+ str := "H"
+ encoded := ToString([]byte(str))
+ rt, err := FromString(encoded)
+ if assert.NoError(t, err) {
+ assert.Equal(t, str, string(rt))
+ }
+}
+
+func TestExtract(t *testing.T) {
+ a := []byte("Here is my string")
+ b := make([]byte, 8)
+ binary.BigEndian.PutUint64(b, 56)
+ str := fmt.Sprintf("hidden%s data%s is fun", ToString(a), ToString(b))
+ t.Log(str)
+ out, err := Extract(str)
+ if assert.NoError(t, err) {
+ if assert.Len(t, out, 2) {
+ assert.Equal(t, out, [][]byte{a, b})
+ }
+ }
+ assert.Equal(t, "hidden data is fun", Clean(str))
+}