From d1db18da5218137b6801bc4fe52d8442555bb112 Mon Sep 17 00:00:00 2001 From: thinkerou Date: Thu, 9 Aug 2018 12:59:06 +0800 Subject: [PATCH] add test case for source --- recovery_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/recovery_test.go b/recovery_test.go index de3b62a5..c91dc9ec 100644 --- a/recovery_test.go +++ b/recovery_test.go @@ -41,3 +41,18 @@ func TestPanicWithAbort(t *testing.T) { // TEST assert.Equal(t, 400, w.Code) } + +func TestSource(t *testing.T) { + bs := source(nil, 0) + assert.Equal(t, []byte("???"), bs) + + in := [][]byte{ + []byte("Hello world."), + []byte("Hi, gin.."), + } + bs = source(in, 10) + assert.Equal(t, []byte("???"), bs) + + bs = source(in, 1) + assert.Equal(t, []byte("Hello world."), bs) +}