當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gspec.New函數代碼示例

本文整理匯總了Golang中github.com/karlseguin/gspec.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/karlseguin/gspec.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。