mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
improve ut case for package gcache/gpool (#2290)
* improve ut case for package gcache/gpool * up
This commit is contained in:
parent
b84034b667
commit
7d1a508ea9
@ -179,6 +179,6 @@ func ExamplePool_Close() {
|
|||||||
// wait for pool close
|
// wait for pool close
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
|
|
||||||
// Output:
|
// May Output:
|
||||||
// Close The Pool
|
// Close The Pool
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,7 @@ func TestCache_LRU(t *testing.T) {
|
|||||||
v, _ := cache.Get(ctx, 6)
|
v, _ := cache.Get(ctx, 6)
|
||||||
t.Assert(v, 6)
|
t.Assert(v, 6)
|
||||||
time.Sleep(4 * time.Second)
|
time.Sleep(4 * time.Second)
|
||||||
|
g.Log().Debugf(ctx, `items after lru: %+v`, cache.MustData(ctx))
|
||||||
n, _ = cache.Size(ctx)
|
n, _ = cache.Size(ctx)
|
||||||
t.Assert(n, 2)
|
t.Assert(n, 2)
|
||||||
v, _ = cache.Get(ctx, 6)
|
v, _ = cache.Get(ctx, 6)
|
||||||
|
@ -17,13 +17,14 @@ func IsSubDomain(subDomain string, mainDomain string) bool {
|
|||||||
if p := strings.IndexByte(mainDomain, ':'); p != -1 {
|
if p := strings.IndexByte(mainDomain, ':'); p != -1 {
|
||||||
mainDomain = mainDomain[0:p]
|
mainDomain = mainDomain[0:p]
|
||||||
}
|
}
|
||||||
subArray := strings.Split(subDomain, ".")
|
var (
|
||||||
mainArray := strings.Split(mainDomain, ".")
|
subArray = strings.Split(subDomain, ".")
|
||||||
subLength := len(subArray)
|
mainArray = strings.Split(mainDomain, ".")
|
||||||
mainLength := len(mainArray)
|
subLength = len(subArray)
|
||||||
|
mainLength = len(mainArray)
|
||||||
|
)
|
||||||
// Eg:
|
// Eg:
|
||||||
// goframe.org is not sub-dome of 's.goframe.org'
|
// "goframe.org" is not sub-domain of "s.goframe.org".
|
||||||
if mainLength > subLength {
|
if mainLength > subLength {
|
||||||
for i := range mainArray[0 : mainLength-subLength] {
|
for i := range mainArray[0 : mainLength-subLength] {
|
||||||
if mainArray[i] != "*" {
|
if mainArray[i] != "*" {
|
||||||
|
Loading…
Reference in New Issue
Block a user