当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.New函数代码示例

本文整理汇总了Golang中github.com/gophergala2016/goad/Godeps/_workspace/src/github.com/stretchr/testify/assert.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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:ernesto-jimenez,项目名称:goad,代码行数:7,代码来源:interpreter_test.go

示例2: TestIsFalseWithNilInterface

func TestIsFalseWithNilInterface(t *testing.T) {
	assert := assert.New(t)
	var a *int = nil
	var nilInterface interface{}
	nilInterface = a
	assert.True(isFalse(nilInterface))
}
开发者ID:ernesto-jimenez,项目名称:goad,代码行数:7,代码来源:util_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:ernesto-jimenez,项目名称:goad,代码行数: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:ernesto-jimenez,项目名称:goad,代码行数:7,代码来源:interpreter_test.go

示例5: 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:ernesto-jimenez,项目名称:goad,代码行数:7,代码来源:interpreter_test.go

示例6: 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:ernesto-jimenez,项目名称:goad,代码行数:7,代码来源:interpreter_test.go

示例7: 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:ernesto-jimenez,项目名称:goad,代码行数:8,代码来源:lexer_test.go

示例8: 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:ernesto-jimenez,项目名称:goad,代码行数:8,代码来源:parser_test.go

示例9: 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:ernesto-jimenez,项目名称:goad,代码行数:8,代码来源:interpreter_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:ernesto-jimenez,项目名称:goad,代码行数: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:ernesto-jimenez,项目名称:goad,代码行数: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:ernesto-jimenez,项目名称:goad,代码行数: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:ernesto-jimenez,项目名称:goad,代码行数:10,代码来源:interpreter_test.go

示例14: 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:ernesto-jimenez,项目名称:goad,代码行数:10,代码来源:util_test.go

示例15: 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:ernesto-jimenez,项目名称:goad,代码行数:10,代码来源:api_test.go


注:本文中的github.com/gophergala2016/goad/Godeps/_workspace/src/github.com/stretchr/testify/assert.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。