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


Golang assert.New函數代碼示例

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


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

示例1: TestCanSupportStructWithOrExpressions

func TestCanSupportStructWithOrExpressions(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", C: nil}
	result, err := Search("C || A", data)
	assert.Nil(err)
	assert.Equal("foo", result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:7,代碼來源:interpreter_test.go

示例2: TestCanSupportStructWithNestedPointers

func TestCanSupportStructWithNestedPointers(t *testing.T) {
	assert := assert.New(t)
	data := struct{ A *struct{ B int } }{}
	result, err := Search("A.B", data)
	assert.Nil(err)
	assert.Nil(result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:7,代碼來源:interpreter_test.go

示例3: TestCanSupportUserDefinedStructsRef

func TestCanSupportUserDefinedStructsRef(t *testing.T) {
	assert := assert.New(t)
	s := scalars{Foo: "one", Bar: "bar"}
	result, err := Search("Foo", &s)
	assert.Nil(err)
	assert.Equal("one", result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:7,代碼來源:interpreter_test.go

示例4: TestCanSupportStructWithFilterProjection

func TestCanSupportStructWithFilterProjection(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{scalars{"f1", "b1"}, scalars{"correct", "b2"}}}
	result, err := Search("B[? `true` ].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"f1", "correct"}, result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:7,代碼來源:interpreter_test.go

示例5: TestCanSupportStructWithSlice

func TestCanSupportStructWithSlice(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{scalars{"f1", "b1"}, scalars{"correct", "b2"}}}
	result, err := Search("B[-1].Foo", data)
	assert.Nil(err)
	assert.Equal("correct", result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:7,代碼來源:interpreter_test.go

示例6: TestIsFalseWithNilInterface

func TestIsFalseWithNilInterface(t *testing.T) {
	assert := assert.New(t)
	var a *int = nil
	var nilInterface interface{}
	nilInterface = a
	assert.True(isFalse(nilInterface))
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:7,代碼來源:util_test.go

示例7: TestParsingErrors

func TestParsingErrors(t *testing.T) {
	assert := assert.New(t)
	parser := NewParser()
	for _, tt := range parsingErrorTests {
		_, err := parser.Parse(tt.expression)
		assert.NotNil(err, fmt.Sprintf("Expected parsing error: %s, for expression: %s", tt.msg, tt.expression))
	}
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:8,代碼來源:parser_test.go

示例8: TestCanSupportEmptyInterface

func TestCanSupportEmptyInterface(t *testing.T) {
	assert := assert.New(t)
	data := make(map[string]interface{})
	data["foo"] = "bar"
	result, err := Search("foo", data)
	assert.Nil(err)
	assert.Equal("bar", result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:8,代碼來源:interpreter_test.go

示例9: TestLexingErrors

func TestLexingErrors(t *testing.T) {
	assert := assert.New(t)
	lexer := NewLexer()
	for _, tt := range lexingErrorTests {
		_, err := lexer.tokenize(tt.expression)
		assert.NotNil(err, fmt.Sprintf("Expected lexing error: %s", tt.msg))
	}
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:8,代碼來源:lexer_test.go

示例10: TestCanSupportProjectionsWithStructs

func TestCanSupportProjectionsWithStructs(t *testing.T) {
	assert := assert.New(t)
	data := nestedSlice{A: []sliceType{
		{A: "first"}, {A: "second"}, {A: "third"},
	}}
	result, err := Search("A[*].A", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"first", "second", "third"}, result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:9,代碼來源:interpreter_test.go

示例11: TestCanSupportFlattenNestedEmptySlice

func TestCanSupportFlattenNestedEmptySlice(t *testing.T) {
	assert := assert.New(t)
	data := nestedSlice{A: []sliceType{
		{}, {B: []scalars{{Foo: "a"}}},
	}}
	result, err := Search("A[].B[].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"a"}, result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:9,代碼來源:interpreter_test.go

示例12: TestIsFalseWithMapOfUserStructs

func TestIsFalseWithMapOfUserStructs(t *testing.T) {
	assert := assert.New(t)
	type foo struct {
		Bar string
		Baz string
	}
	m := make(map[int]foo)
	assert.True(isFalse(m))
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:9,代碼來源:util_test.go

示例13: TestWillAutomaticallyCapitalizeFieldNames

func TestWillAutomaticallyCapitalizeFieldNames(t *testing.T) {
	assert := assert.New(t)
	s := scalars{Foo: "one", Bar: "bar"}
	// Note that there's a lower cased "foo" instead of "Foo",
	// but it should still correspond to the Foo field in the
	// scalars struct
	result, err := Search("foo", &s)
	assert.Nil(err)
	assert.Equal("one", result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:10,代碼來源:interpreter_test.go

示例14: TestValidPrecompiledExpressionSearches

func TestValidPrecompiledExpressionSearches(t *testing.T) {
	assert := assert.New(t)
	data := make(map[string]interface{})
	data["foo"] = "bar"
	precompiled, err := Compile("foo")
	assert.Nil(err)
	result, err := precompiled.Search(data)
	assert.Nil(err)
	assert.Equal("bar", result)
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:10,代碼來源:api_test.go

示例15: TestObjsEqual

func TestObjsEqual(t *testing.T) {
	assert := assert.New(t)
	assert.True(objsEqual("foo", "foo"))
	assert.True(objsEqual(20, 20))
	assert.True(objsEqual([]int{1, 2, 3}, []int{1, 2, 3}))
	assert.True(objsEqual(nil, nil))
	assert.True(!objsEqual(nil, "foo"))
	assert.True(objsEqual([]int{}, []int{}))
	assert.True(!objsEqual([]int{}, nil))
}
開發者ID:kuenzaa,項目名稱:rack,代碼行數:10,代碼來源:util_test.go


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