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


Golang Assertion.Nil方法代码示例

本文整理汇总了Golang中github.com/tideland/golib/audit.Assertion.Nil方法的典型用法代码示例。如果您正苦于以下问题:Golang Assertion.Nil方法的具体用法?Golang Assertion.Nil怎么用?Golang Assertion.Nil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tideland/golib/audit.Assertion的用法示例。


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

示例1: createNodeStructure

// Create a node structure.
func createNodeStructure(assert audit.Assertion) sml.Node {
	builder := sml.NewNodeBuilder()

	builder.BeginTagNode("root")

	builder.TextNode("Text A")
	builder.TextNode("Text B")
	builder.CommentNode("A first comment.")

	builder.BeginTagNode("sub-a:1st:important")
	builder.TextNode("Text A.A")
	builder.CommentNode("A second comment.")
	builder.EndTagNode()

	builder.BeginTagNode("sub-b:2nd")
	builder.TextNode("Text B.A")
	builder.BeginTagNode("text")
	builder.TextNode("Any text with the special characters {, }, and ^.")
	builder.EndTagNode()
	builder.EndTagNode()

	builder.BeginTagNode("sub-c")
	builder.TextNode("Before raw.")
	builder.RawNode("func Test(i int) { println(i) }")
	builder.TextNode("After raw.")
	builder.EndTagNode()

	builder.EndTagNode()

	root, err := builder.Root()
	assert.Nil(err)

	return root
}
开发者ID:kung-foo,项目名称:golib,代码行数:35,代码来源:sml_test.go

示例2: createConfigurationFile

// createConfigurationFile creates a temporary configuration file.
func createConfigurationFile(assert audit.Assertion, content string) (*audit.TempDir, string) {
	tempDir := audit.NewTempDir(assert)
	configFile, err := ioutil.TempFile(tempDir.String(), "configuration")
	assert.Nil(err)
	configFileName := configFile.Name()
	_, err = configFile.WriteString(content)
	assert.Nil(err)
	configFile.Close()

	return tempDir, configFileName
}
开发者ID:tideland,项目名称:gocells,代码行数:12,代码来源:configurator_test.go

示例3: pipelineDatabase

// pipelineDatabase connects to a Redis database with the given options
// and returns a pipeling and a function for closing. This function
// shall be called with a defer.
func pipelineDatabase(assert audit.Assertion, options ...redis.Option) (*redis.Pipeline, func()) {
	// Open and connect database.
	options = append(options, redis.Index(testDatabaseIndex, ""))
	db, err := redis.Open(options...)
	assert.Nil(err)
	ppl, err := db.Pipeline()
	assert.Nil(err)
	// Return pipeline and cleanup function.
	return ppl, func() {
		db.Close()
	}
}
开发者ID:kung-foo,项目名称:golib,代码行数:15,代码来源:redis_test.go

示例4: subscribeDatabase

// subscribeDatabase connects to a Redis database with the given options
// and returns a subscription and a function for closing. This function
// shall be called with a defer.
func subscribeDatabase(assert audit.Assertion, options ...redis.Option) (*redis.Subscription, func()) {
	// Open and connect database.
	options = append(options, redis.Index(testDatabaseIndex, ""))
	db, err := redis.Open(options...)
	assert.Nil(err)
	sub, err := db.Subscription()
	assert.Nil(err)
	// Return subscription and cleanup function.
	return sub, func() {
		sub.Close()
		db.Close()
	}
}
开发者ID:kung-foo,项目名称:golib,代码行数:16,代码来源:redis_test.go

示例5: connectDatabase

// connectDatabase connects to a Redis database with the given options
// and returns a connection and a function for closing. This function
// shall be called with defer.
func connectDatabase(assert audit.Assertion, options ...redis.Option) (*redis.Connection, func()) {
	// Open and connect database.
	options = append(options, redis.Index(testDatabaseIndex, ""))
	db, err := redis.Open(options...)
	assert.Nil(err)
	conn, err := db.Connection()
	assert.Nil(err)
	// Flush all keys to get a clean testing environment.
	_, err = conn.Do("flushdb")
	assert.Nil(err)
	// Return connection and cleanup function.
	return conn, func() {
		conn.Return()
		db.Close()
	}
}
开发者ID:kung-foo,项目名称:golib,代码行数:19,代码来源:redis_test.go

示例6: createKeyStringValueTree

func createKeyStringValueTree(assert audit.Assertion) collections.KeyStringValueTree {
	tree := collections.NewKeyStringValueTree("root", "one", true)
	err := tree.At("root").Add("alpha", "two")
	assert.Nil(err)
	err = tree.At("root").Add("bravo", "three")
	assert.Nil(err)
	err = tree.At("root", "bravo").Add("foo", "bar")
	assert.Nil(err)
	err = tree.At("root", "bravo").Add("bar", "foo")
	assert.Nil(err)
	err = tree.At("root").Add("bravo", "four")
	assert.Nil(err)
	err = tree.At("root").Add("charlie", "five")
	assert.Nil(err)
	err = tree.Create("root", "delta", "one").Add("true", "one")
	assert.Nil(err)
	err = tree.Create("root", "delta", "two").Add("false", "zero")
	assert.Nil(err)
	assert.Length(tree, 12)

	return tree
}
开发者ID:jmptrader,项目名称:golib,代码行数:22,代码来源:tree_test.go

示例7: createTree

func createTree(assert audit.Assertion) collections.Tree {
	tree := collections.NewTree("root", true)
	err := tree.At("root").Add("alpha")
	assert.Nil(err)
	err = tree.At("root").Add("bravo")
	assert.Nil(err)
	err = tree.At("root", "bravo").Add("foo")
	assert.Nil(err)
	err = tree.At("root", "bravo").Add("bar")
	assert.Nil(err)
	err = tree.At("root").Add("bravo")
	assert.Nil(err)
	err = tree.At("root").Add("charlie")
	assert.Nil(err)
	err = tree.Create("root", "delta", 1).Add(true)
	assert.Nil(err)
	err = tree.Create("root", "delta", 2).Add(false)
	assert.Nil(err)
	assert.Length(tree, 12)

	return tree
}
开发者ID:jmptrader,项目名称:golib,代码行数:22,代码来源:tree_test.go

示例8: assertNil

// assertNil checks if the result at index is nil.
func assertNil(assert audit.Assertion, result *redis.ResultSet, index int) {
	v, err := result.ValueAt(index)
	assert.Nil(err)
	assert.Nil(v)
}
开发者ID:kung-foo,项目名称:golib,代码行数:6,代码来源:redis_test.go

示例9: assertEqualInt

// assertEqualInt checks if the result at index is value.
func assertEqualInt(assert audit.Assertion, result *redis.ResultSet, index, value int) {
	i, err := result.IntAt(index)
	assert.Nil(err)
	assert.Equal(i, value)
}
开发者ID:kung-foo,项目名称:golib,代码行数:6,代码来源:redis_test.go

示例10: assertEqualBool

// assertEqualBool checks if the result at index is value.
func assertEqualBool(assert audit.Assertion, result *redis.ResultSet, index int, value bool) {
	b, err := result.BoolAt(index)
	assert.Nil(err)
	assert.Equal(b, value)
}
开发者ID:kung-foo,项目名称:golib,代码行数:6,代码来源:redis_test.go

示例11: assertEqualString

// assertEqualString checks if the result at index is value.
func assertEqualString(assert audit.Assertion, result *redis.ResultSet, index int, value string) {
	s, err := result.StringAt(index)
	assert.Nil(err)
	assert.Equal(s, value)
}
开发者ID:kung-foo,项目名称:golib,代码行数:6,代码来源:redis_test.go


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