本文整理汇总了Golang中github.com/stretchr/testify/assert.Assertions.Contains方法的典型用法代码示例。如果您正苦于以下问题:Golang Assertions.Contains方法的具体用法?Golang Assertions.Contains怎么用?Golang Assertions.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/stretchr/testify/assert.Assertions
的用法示例。
在下文中一共展示了Assertions.Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: asserChannelContainsEntries
func asserChannelContainsEntries(a *assert.Assertions, entryC chan [2]string, expectedEntries ...[2]string) {
allEntries := make([][2]string, 0)
loop:
for {
select {
case entry, ok := <-entryC:
if !ok {
break loop
}
allEntries = append(allEntries, entry)
case <-time.After(time.Second):
a.Fail("timeout")
}
}
a.Equal(len(expectedEntries), len(allEntries))
for _, expected := range expectedEntries {
a.Contains(allEntries, expected)
}
}
示例2: assertChannelContains
func assertChannelContains(a *assert.Assertions, entryC chan string, expectedEntries ...string) {
var allEntries []string
WAITLOOP:
for {
select {
case entry, ok := <-entryC:
if !ok {
break WAITLOOP
}
allEntries = append(allEntries, entry)
case <-time.After(time.Second):
a.Fail("timeout")
}
}
a.Equal(len(expectedEntries), len(allEntries))
for _, expected := range expectedEntries {
a.Contains(allEntries, expected)
}
}
示例3: assertListContainsAll
func assertListContainsAll(assert *assert.Assertions, list interface{}, items ...interface{}) {
assert.Len(list, len(items))
for _, item := range items {
assert.Contains(list, item)
}
}
示例4: assertSubsidiaries
func assertSubsidiaries(assert *assert.Assertions, actual []Subsidiary, items ...Subsidiary) {
assert.Len(actual, len(items))
for _, item := range items {
assert.Contains(actual, item)
}
}