本文整理汇总了Golang中github.com/karlseguin/gspec.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestInvalidWhenStringIsTooShort
func TestInvalidWhenStringIsTooShort(t *testing.T) {
spec := gspec.New(t)
rule := MinLen(4)
for _, str := range []string{"1", "12", "123"} {
spec.Expect(rule.Verify(str)).ToEqual(false)
}
}
开发者ID:karlseguin,项目名称:auwfg,代码行数:7,代码来源:minlen_test.go
示例2: TestInvalidWhenStringIsTooLong
func TestInvalidWhenStringIsTooLong(t *testing.T) {
spec := gspec.New(t)
rule := MaxLen(4)
for _, str := range []string{"12345", "123456"} {
spec.Expect(rule.Verify(str)).ToEqual(false)
}
}
开发者ID:karlseguin,项目名称:auwfg,代码行数:7,代码来源:maxlen_test.go
示例3: TestParserReadsContainsCondition
func TestParserReadsContainsCondition(t *testing.T) {
spec := gspec.New(t)
parser := newParser(" 'xyz' contains true%}")
group, err := parser.ReadConditionGroup()
spec.Expect(err).ToBeNil()
assertParsedConditionGroup(t, group, "xyz", Contains, true)
}
开发者ID:karlseguin,项目名称:liquid,代码行数:7,代码来源:parser_test.go
示例4: TestSetsTheNotFoundResponse
func TestSetsTheNotFoundResponse(t *testing.T) {
spec := gspec.New(t)
expected := Json("the res").Status(244).Response
actual := Configure().NotFoundResponse(expected).notFound
spec.Expect(actual.GetStatus()).ToEqual(244)
spec.Expect(string(actual.GetBody())).ToEqual("the res")
}
开发者ID:karlseguin,项目名称:auwfg,代码行数:7,代码来源:configuration_test.go
示例5: TestReverseASingleElementArray
func TestReverseASingleElementArray(t *testing.T) {
spec := gspec.New(t)
filter := ReverseFactory(nil)
values := filter([]bool{true}, nil).([]bool)
spec.Expect(len(values)).ToEqual(1)
spec.Expect(values[0]).ToEqual(true)
}
开发者ID:karlseguin,项目名称:liquid,代码行数:7,代码来源:reverse_test.go
示例6: TestSetContainsAnExistingIdIfMultipleIndexesContainsIt
func TestSetContainsAnExistingIdIfMultipleIndexesContainsIt(t *testing.T) {
spec := gspec.New(t)
union := NewUnion("x", []string{"apple", "orange"})
union.On(makeSetIndex(20, 23, 24, 25, 26))
union.On(makeSetIndex(20, 25, 28, 29))
spec.Expect(union.Contains(key.Type(20))).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:union_test.go
示例7: TestValidWhenStringLengthIsWithinLen
func TestValidWhenStringLengthIsWithinLen(t *testing.T) {
spec := gspec.New(t)
rule := Len(4, 6)
for _, str := range []string{"1234", "12345", "123456"} {
spec.Expect(rule.Verify(str)).ToEqual(true)
}
}
开发者ID:karlseguin,项目名称:auwfg,代码行数:7,代码来源:len_test.go
示例8: TestMockIsLimitedToASingleInvocation
func TestMockIsLimitedToASingleInvocation(t *testing.T) {
spec := gspec.New(t)
fake := newFake()
fake.Expect(fake.GetEmail).Returning("first").Once()
spec.Expect(fake.GetEmail("leto")).ToEqual("first")
spec.Expect(fake.GetEmail("paul")).ToEqual("[email protected]")
}
开发者ID:karlseguin,项目名称:gofake,代码行数:7,代码来源:mock_test.go
示例9: TestMockReturnsTheValueOnceByDefaultTimes
func TestMockReturnsTheValueOnceByDefaultTimes(t *testing.T) {
spec := gspec.New(t)
fake := newFake()
fake.Expect(fake.GetEmail).Returning("invalid")
spec.Expect(fake.GetEmail("leto")).ToEqual("invalid")
spec.Expect(fake.GetEmail("paul")).ToEqual("[email protected]")
}
开发者ID:karlseguin,项目名称:gofake,代码行数:7,代码来源:mock_test.go
示例10: assertStaticValue
func assertStaticValue(t *testing.T, data string, expected interface{}) {
spec := gspec.New(t)
p := NewParser([]byte(data))
value, err := p.ReadValue()
spec.Expect(err).ToBeNil()
spec.Expect(value.Resolve(nil)).ToEqual(expected)
}
开发者ID:ChaosCloud,项目名称:gerb,代码行数:7,代码来源:parser_test.go
示例11: assertErrorValue
func assertErrorValue(t *testing.T, data string, expected string) {
spec := gspec.New(t)
p := NewParser([]byte(data))
value, err := p.ReadValue()
spec.Expect(err.Error()).ToEqual(expected)
spec.Expect(value).ToBeNil()
}
开发者ID:ChaosCloud,项目名称:gerb,代码行数:7,代码来源:parser_test.go
示例12: TestStubReturnsTheValueMultipleTimes
func TestStubReturnsTheValueMultipleTimes(t *testing.T) {
spec := gspec.New(t)
fake := newFake()
fake.Stub(fake.GetEmail).Returning("invalid")
spec.Expect(fake.GetEmail("leto")).ToEqual("invalid")
spec.Expect(fake.GetEmail("paul")).ToEqual("invalid")
}
开发者ID:karlseguin,项目名称:gofake,代码行数:7,代码来源:stub_test.go
示例13: TestQueryCapsTheLimit
func TestQueryCapsTheLimit(t *testing.T) {
spec := gspec.New(t)
db := SmallDB()
defer db.Close()
query := <-db.queryPool
spec.Expect(query.Limit(200).(*NormalQuery).limit).ToEqual(100)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:query_test.go
示例14: TestEmptyQueryOnInvalidIndex
func TestEmptyQueryOnInvalidIndex(t *testing.T) {
spec := gspec.New(t)
db := SmallDB()
defer db.Close()
_, ok := db.Query("cats").(*EmptyQuery)
spec.Expect(ok).ToEqual(true)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:query_test.go
示例15: TestParserReadsASinglePartial
func TestParserReadsASinglePartial(t *testing.T) {
spec := gspec.New(t)
parser := newParser(" true %}")
group, err := parser.ReadPartialCondition()
spec.Expect(err).ToBeNil()
assertParsedConditionGroup(t, group, true, UnknownComparator, nil)
}
开发者ID:karlseguin,项目名称:liquid,代码行数:7,代码来源:parser_test.go
示例16: TestIdMapReturnsAnExistingId
func TestIdMapReturnsAnExistingId(t *testing.T) {
spec := gspec.New(t)
m := newIdMap()
m.get("over", true)
m.get("9000", true)
spec.Expect(m.get("over", false)).ToEqual(key.Type(1))
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:idmap_test.go
示例17: TestParserReadsMultiplePartials
func TestParserReadsMultiplePartials(t *testing.T) {
spec := gspec.New(t)
parser := newParser(" 1 or 2%}")
group, err := parser.ReadPartialCondition()
spec.Expect(err).ToBeNil()
assertParsedConditionGroup(t, group, 1, UnknownComparator, nil, OR, 2, UnknownComparator, nil)
}
开发者ID:karlseguin,项目名称:liquid,代码行数:7,代码来源:parser_test.go
示例18: TestIdMapRemovesAnId
func TestIdMapRemovesAnId(t *testing.T) {
spec := gspec.New(t)
m := newIdMap()
m.get("over", true)
m.remove("over")
spec.Expect(m.get("over", false)).ToEqual(key.NULL)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:idmap_test.go
示例19: TestUnionDoesNotContainANonExistantId
func TestUnionDoesNotContainANonExistantId(t *testing.T) {
spec := gspec.New(t)
union := NewUnion("x", []string{"apple", "orange"})
union.On(makeSetIndex(20, 23, 24, 25, 26))
union.On(makeSetIndex(20, 25, 28, 29))
spec.Expect(union.Contains(key.Type(22))).ToEqual(false)
}
开发者ID:Wexcode,项目名称:nabu,代码行数:7,代码来源:union_test.go
示例20: TestParserReadsAUnaryCondition
func TestParserReadsAUnaryCondition(t *testing.T) {
spec := gspec.New(t)
parser := newParser(" true %}")
group, err := parser.ReadConditionGroup()
spec.Expect(err).ToBeNil()
assertParsedConditionGroup(t, group, true, Unary, nil)
}
开发者ID:karlseguin,项目名称:liquid,代码行数:7,代码来源:parser_test.go
注:本文中的github.com/karlseguin/gspec.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论