mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 21:28:22 +08:00
improve unit test cases for gpool
This commit is contained in:
parent
373dbde42c
commit
717dae8f5d
@ -1,7 +1,14 @@
|
|||||||
|
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the MIT License.
|
||||||
|
// If a copy of the MIT was not distributed with this file,
|
||||||
|
// You can obtain one at https://github.com/gogf/gf.
|
||||||
|
|
||||||
package gpool_test
|
package gpool_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/gogf/gf/g"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -30,7 +37,7 @@ func Test_Gpool(t *testing.T) {
|
|||||||
//test won't be timeout
|
//test won't be timeout
|
||||||
v1, err1 := p1.Get()
|
v1, err1 := p1.Get()
|
||||||
gtest.Assert(err1, nil)
|
gtest.Assert(err1, nil)
|
||||||
gtest.Assert(v1, 1)
|
gtest.AssertIN(v1, g.Slice{1, 2})
|
||||||
//test clear
|
//test clear
|
||||||
p1.Clear()
|
p1.Clear()
|
||||||
gtest.Assert(p1.Size(), 0)
|
gtest.Assert(p1.Size(), 0)
|
||||||
@ -43,13 +50,12 @@ func Test_Gpool(t *testing.T) {
|
|||||||
p1.Put(4)
|
p1.Put(4)
|
||||||
v1, err1 = p1.Get()
|
v1, err1 = p1.Get()
|
||||||
gtest.Assert(err1, nil)
|
gtest.Assert(err1, nil)
|
||||||
gtest.Assert(v1, 3)
|
gtest.AssertIN(v1, g.Slice{3, 4})
|
||||||
//test close
|
//test close
|
||||||
p1.Close()
|
p1.Close()
|
||||||
v1, err1 = p1.Get()
|
v1, err1 = p1.Get()
|
||||||
gtest.Assert(err1, nil)
|
gtest.Assert(err1, nil)
|
||||||
gtest.Assert(v1, "hello")
|
gtest.Assert(v1, "hello")
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
gtest.Case(t, func() {
|
gtest.Case(t, func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user