diff options
Diffstat (limited to 'vendor/github.com/segmentio/backo-go')
6 files changed, 161 insertions, 0 deletions
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore new file mode 100644 index 000000000..b6fadf4eb --- /dev/null +++ b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore @@ -0,0 +1,7 @@ +_go_.* +_gotest_.* +_obj +_test +_testmain.go +*.out +*.[568] diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md new file mode 100644 index 000000000..8b6b6fc4f --- /dev/null +++ b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md @@ -0,0 +1,45 @@ +# Assert (c) Blake Mizerany and Keith Rarick -- MIT LICENCE + +## Assertions for Go tests + +## Install + + $ go get github.com/bmizerany/assert + +## Use + +**point.go** + + package point + + type Point struct { + x, y int + } + +**point_test.go** + + + package point + + import ( + "testing" + "github.com/bmizerany/assert" + ) + + func TestAsserts(t *testing.T) { + p1 := Point{1, 1} + p2 := Point{2, 1} + + assert.Equal(t, p1, p2) + } + +**output** + $ go test + --- FAIL: TestAsserts (0.00 seconds) + assert.go:15: /Users/flavio.barbosa/dev/stewie/src/point_test.go:12 + assert.go:24: ! X: 1 != 2 + FAIL + +## Docs + + http://github.com/bmizerany/assert diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go new file mode 100644 index 000000000..7409f985e --- /dev/null +++ b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go @@ -0,0 +1,76 @@ +package assert +// Testing helpers for doozer. + +import ( + "github.com/kr/pretty" + "reflect" + "testing" + "runtime" + "fmt" +) + +func assert(t *testing.T, result bool, f func(), cd int) { + if !result { + _, file, line, _ := runtime.Caller(cd + 1) + t.Errorf("%s:%d", file, line) + f() + t.FailNow() + } +} + +func equal(t *testing.T, exp, got interface{}, cd int, args ...interface{}) { + fn := func() { + for _, desc := range pretty.Diff(exp, got) { + t.Error("!", desc) + } + if len(args) > 0 { + t.Error("!", " -", fmt.Sprint(args...)) + } + } + result := reflect.DeepEqual(exp, got) + assert(t, result, fn, cd+1) +} + +func tt(t *testing.T, result bool, cd int, args ...interface{}) { + fn := func() { + t.Errorf("! Failure") + if len(args) > 0 { + t.Error("!", " -", fmt.Sprint(args...)) + } + } + assert(t, result, fn, cd+1) +} + +func T(t *testing.T, result bool, args ...interface{}) { + tt(t, result, 1, args...) +} + +func Tf(t *testing.T, result bool, format string, args ...interface{}) { + tt(t, result, 1, fmt.Sprintf(format, args...)) +} + +func Equal(t *testing.T, exp, got interface{}, args ...interface{}) { + equal(t, exp, got, 1, args...) +} + +func Equalf(t *testing.T, exp, got interface{}, format string, args ...interface{}) { + equal(t, exp, got, 1, fmt.Sprintf(format, args...)) +} + +func NotEqual(t *testing.T, exp, got interface{}, args ...interface{}) { + fn := func() { + t.Errorf("! Unexpected: <%#v>", exp) + if len(args) > 0 { + t.Error("!", " -", fmt.Sprint(args...)) + } + } + result := !reflect.DeepEqual(exp, got) + assert(t, result, fn, 1) +} + +func Panic(t *testing.T, err interface{}, fn func()) { + defer func() { + equal(t, err, recover(), 3) + }() + fn() +} diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go new file mode 100644 index 000000000..162a590c6 --- /dev/null +++ b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go @@ -0,0 +1,15 @@ +package assert + +import ( + "testing" +) + +func TestLineNumbers(t *testing.T) { + Equal(t, "foo", "foo", "msg!") + //Equal(t, "foo", "bar", "this should blow up") +} + +func TestNotEqual(t *testing.T) { + NotEqual(t, "foo", "bar", "msg!") + //NotEqual(t, "foo", "foo", "this should blow up") +} diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go new file mode 100644 index 000000000..15789fe10 --- /dev/null +++ b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go @@ -0,0 +1,5 @@ +package point + +type Point struct { + X, Y int +} diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go new file mode 100644 index 000000000..34e791a43 --- /dev/null +++ b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go @@ -0,0 +1,13 @@ +package point + +import ( + "testing" + "assert" +) + +func TestAsserts(t *testing.T) { + p1 := Point{1, 1} + p2 := Point{2, 1} + + assert.Equal(t, p1, p2) +} |