代码拉取完成,页面将自动刷新
package tug
import (
"container/list"
"fmt"
)
type emptyList struct {
reason string
}
func (this *emptyList) Match(actual interface{}) bool {
list, ok := actual.(*list.List)
if ok {
return list==nil||list.Len()== 0
}else{
panic(fmt.Sprintf("type not match List.list,%T(actual)",list))
}
return false
}
func (this *emptyList)FailReason(actual interface{})string {
return fmt.Sprintf(this.reason,actual,LOGIC_NOT)
}
func (this *emptyList)NegationFailReason(actual interface{})string {
return fmt.Sprintf(this.reason,actual)
}
func EmptyList() Matcher {
return &emptyList{
reason:"list is %s nil, %v(actual)",
}
}
type hasItems struct {
BaseMatcher
}
func (this *hasItems) Match(actual interface{}) bool {
list, ok := actual.(*list.List)
if !ok {
panic(fmt.Sprintf("type not match List.list,%T(actual)",list))
}
flag := false
for e := list.Front(); e != nil; e = e.Next() {
if e.Value == this.Expected {
flag = true
break
}
}
return flag
}
func (this *hasItems)FailReason(actual interface{})string {
return fmt.Sprintf(this.Reason,EMPTY,this.Expected)
}
func (this *hasItems)NegationFailReason(actual interface{})string {
return fmt.Sprintf(this.Reason,LOGIC_NOT,this.Expected)
}
func HasItems(expected interface{}) Matcher {
matcher := &hasItems{}
matcher.Expected=expected
matcher.Reason="list is %s contain %v(excepted)"
return matcher
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。