本文整理汇总了Golang中github.com/interactiv/expect.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestReverse
func TestReverse(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{1, 2, 3}).Reverse().Out(&result)
e.Expect(err).ToBeNil()
e.Expect(result[0]).ToEqual(3)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例2: TestLastIndexOf
func TestLastIndexOf(t *testing.T) {
e := expect.New(t)
var result int = -1
err := pipeline.In("abba").LastIndexOf('a', 0).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(result).ToEqual(3)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例3: TestConcat
func TestConcat(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{}).Concat([]int{1, 2, 3}, []int{4, 5, 6}).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(len(result)).ToEqual(6)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例4: TestCompact
func TestCompact(t *testing.T) {
e := expect.New(t)
var result1 []interface{}
err := pipeline.In([]interface{}{1, nil, 2, 'a', nil}).Compact().Out(&result1)
e.Expect(err).ToBeNil()
e.Expect(fmt.Sprint(result1)).ToEqual(fmt.Sprint([]interface{}{1, 2, 'a'}))
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例5: TestUnion
func TestUnion(t *testing.T) {
e := expect.New(t)
var res []int
err := pipeline.In([]int{1, 2}).Union([]int{2, 3}, []int{3, 4}).Out(&res)
e.Expect(err).ToBeNil()
e.Expect(fmt.Sprint(res)).ToEqual(fmt.Sprint([]int{1, 2, 3, 4}))
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例6: TestIntersection
func TestIntersection(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{1, 2, 4}).Intersection([]int{3, 2, 1}, []int{2, 5, 6}).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(fmt.Sprint(result)).ToEqual(fmt.Sprint([]int{2}))
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例7: TestGroupBy
func TestGroupBy(t *testing.T) {
e := expect.New(t)
var result map[int][]Person
err := pipeline.In([]Person{{12, "John"}, {12, "Jane"}, {20, "Joe"}}).
GroupBy(func(el interface{}, i int) interface{} {
return el.(Person).Age
}).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(len(result)).ToEqual(2)
e.Expect(len(result[12])).ToEqual(2)
e.Expect(result[12][0].Age).ToEqual(12)
var result1 map[string][]map[string]string
err = pipeline.In([]map[string]string{
{"product": "trousers", "category": "clothes"},
{"product": "beer", "category": "drinks"},
{"product": "coat", "category": "clothes"},
}).
GroupBy(func(el interface{}, i int) interface{} {
return el.(map[string]string)["category"]
}).Out(&result1)
e.Expect(err).ToBeNil()
e.Expect(len(result1)).ToEqual(2)
e.Expect(len(result1["clothes"])).ToEqual(2)
e.Expect(len(result1["drinks"])).ToEqual(1)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:28,代码来源:pipeline_test.go
示例8: TestMap
func TestMap(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{1, 2, 3}).Map(func(element interface{}, index int) interface{} {
return element.(int) * 2
}).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(len(result)).ToEqual(3)
e.Expect(result[0]).ToEqual(2)
var result2 *[]int
err = pipeline.In(&[]int{1, 2, 3}).Out(&result2)
e.Expect(err).ToBeNil()
e.Expect(fmt.Sprint(result2)).ToEqual(fmt.Sprint(&[]int{1, 2, 3}))
var result3 string
err = pipeline.In("foo").Out(&result3)
e.Expect(err).ToBeNil()
e.Expect(result3).ToBe("foo")
var result4 []string
err = pipeline.In([]int{1, 2, 3}).Out(&result4)
e.Expect(err).Not().ToBeNil()
t.Log(err)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:25,代码来源:pipeline_test.go
示例9: TestLast
func TestLast(t *testing.T) {
e := expect.New(t)
var result int
err := pipeline.In([]int{1, 3, 6}).Last().Out(&result)
e.Expect(err).ToBeNil()
e.Expect(result).ToEqual(6)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:7,代码来源:pipeline_test.go
示例10: TestCompositeExpression
func TestCompositeExpression(t *testing.T) {
e := expect.New(t)
expr := &expression.Composite{expression.OR, []string{"u.group_id = 1"}}
e.Expect(expr.Length()).ToBe(1)
expr.Add("u.group_id = 2")
e.Expect(expr.Length()).ToBe(2)
}
开发者ID:interactiv,项目名称:dbal,代码行数:7,代码来源:composite_test.go
示例11: TestComparison
func TestComparison(t *testing.T) {
e := expect.New(t)
for _, fixture := range provideDataForComparison() {
part := expr().Comparison(fixture.x, fixture.Type, fixture.y)
e.Expect(part).ToEqual(fixture.expected)
}
}
开发者ID:interactiv,项目名称:dbal,代码行数:8,代码来源:builder_test.go
示例12: TestUnique
func TestUnique(t *testing.T) {
e := expect.New(t)
var result []string
err := pipeline.In([]string{"a", "b", "b", "a"}).Unique().Out(&result)
e.Expect(err).ToBeNil()
e.Expect(len(result)).ToEqual(2)
e.Expect(result[1]).ToEqual("b")
}
开发者ID:interactiv,项目名称:pipeline,代码行数:8,代码来源:pipeline_test.go
示例13: TestToMap
func TestToMap(t *testing.T) {
e := expect.New(t)
in := map[string]string{"a": "angel", "b": "bookmark", "c": "card"}
result := pipeline.In(in).ToMap(func(val interface{}, key interface{}) (interface{}, interface{}) {
return key, val
}).MustOut()
e.Expect(result.(map[interface{}]interface{})["angel"]).ToEqual("a")
}
开发者ID:interactiv,项目名称:pipeline,代码行数:8,代码来源:pipeline_test.go
示例14: TestFlatten
func TestFlatten(t *testing.T) {
e := expect.New(t)
var result []int
Error := pipeline.In([]interface{}{[]int{1, 2}, 3, []int{4, 5}}).Flatten().Out(&result)
e.Expect(Error).ToBeNil()
e.Expect(len(result)).ToEqual(5)
t.Log(result)
}
开发者ID:interactiv,项目名称:pipeline,代码行数:8,代码来源:pipeline_test.go
示例15: TestChunk
func TestChunk(t *testing.T) {
e := expect.New(t)
var result [][]int
err := pipeline.In([]int{1, 2, 3, 4, 5}).Chunk(2).Out(&result)
e.Expect(err).ToBeNil()
t.Log(result)
e.Expect(fmt.Sprint(result)).ToEqual(fmt.Sprint([][]int{{1, 2}, {3, 4}, {5}}))
}
开发者ID:interactiv,项目名称:pipeline,代码行数:9,代码来源:pipeline_test.go
示例16: TestPush
func TestPush(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{2, 3, 4}).Push(5, 6, 7).Out(&result)
e.Expect(err).ToBeNil()
for i, val := range []int{2, 3, 4, 5, 6, 7} {
e.Expect(result[i]).ToEqual(val)
}
}
开发者ID:interactiv,项目名称:pipeline,代码行数:9,代码来源:pipeline_test.go
示例17: TestSome
func TestSome(t *testing.T) {
e := expect.New(t)
var result bool
err := pipeline.In([]int{1, 3, 6}).Some(func(element interface{}, index int) bool {
return element.(int)%2 == 0
}).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(result).ToBeTrue()
}
开发者ID:interactiv,项目名称:pipeline,代码行数:9,代码来源:pipeline_test.go
示例18: TestUnshift
func TestUnshift(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{3, 4}).Unshift(1, 2).Out(&result)
e.Expect(err).ToBeNil()
for i, val := range []int{1, 2, 3, 4} {
e.Expect(result[i]).ToEqual(val)
}
}
开发者ID:interactiv,项目名称:pipeline,代码行数:10,代码来源:pipeline_test.go
示例19: TestSlice
func TestSlice(t *testing.T) {
e := expect.New(t)
var result []int
err := pipeline.In([]int{1, 2, 3, 4}).Slice(0, 2).Out(&result)
e.Expect(err).ToBeNil()
e.Expect(len(result)).ToEqual(3)
for i, val := range []int{1, 2, 3} {
e.Expect(result[i]).ToEqual(val)
}
}
开发者ID:interactiv,项目名称:pipeline,代码行数:10,代码来源:pipeline_test.go
示例20: TestAndX
func TestAndX(t *testing.T) {
e := expect.New(t)
for _, fixture := range provideDataForAndX() {
composite := expr().AndX()
for _, part := range fixture.parts {
composite.Add(part)
}
e.Expect(composite.String()).ToEqual(fixture.expected)
}
}
开发者ID:interactiv,项目名称:dbal,代码行数:10,代码来源:builder_test.go
注:本文中的github.com/interactiv/expect.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论