• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Test_getHeaders

func Test_getHeaders(t *testing.T) {
	// Prepare test
	p := &person{}
	fields, structName := getFields(p)
	assert.Equal(t, "csvutil.person", structName)

	// Start test
	headers := getHeaders(fields)
	assert.Equal(t, CsvHeader{"Name": 0, "Age": 1, "Balance": 2, "LowBalance": 3}, headers)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:10,代码来源:csvutil_test.go


示例2: Test_pickingColumns

func Test_pickingColumns(t *testing.T) {
	// Prepare test
	sr := NewStringReadCloser(strings.Join(testCsvLines, "\n"))
	c := NewCsvUtil(sr).Comma('|').TrailingComma(true).FieldsPerRecord(-1)

	c.Header(map[string]int{"Name": 0, "Balance": 2})

	// Start test
	p := &person2{}
	err := c.SetData(p)
	assert.NotError(t, err)

	assert.Equal(t, "Tony", p.Name)
	assert.Equal(t, float32(123.456), p.Balance)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:15,代码来源:csvutil_test.go


示例3: Test_trim

func Test_trim(t *testing.T) {
	// Prepare test
	sr := NewStringReadCloser("   Tom |12|123|T")
	c := NewCsvUtil(sr).Comma('|').Trim(" ")

	// Start test
	p := &person{}
	err := c.SetData(p)
	assert.NotError(t, err)

	assert.Equal(t, "Tom", p.Name)
	assert.Equal(t, 12, p.Age)
	assert.Equal(t, float32(123), p.Balance)
	assert.Equal(t, true, p.LowBalance)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:15,代码来源:csvutil_test.go


示例4: Test_GetTableNames

func Test_GetTableNames(t *testing.T) {
	dbcon.Close()
	tableNames, err := GetTableNames()
	if err == nil {
		t.Fatal("Expected database error.")
	}
	dbcon.Connect()

	createSql := `
	CREATE TABLE %s (
	  Id int(11) unsigned NOT NULL,
	  Field int(11) DEFAULT NULL,
	  PRIMARY KEY (id)
	) ENGINE=%s`

	for x := 0; x < 4; x++ {
		_, _, err = dbcon.Query(fmt.Sprintf(createSql, "test"+strconv.FormatInt(int64(x), 10), TEST_DB_ENGINE))
		if err != nil {
			t.Fatal("Did not expect database error: " + err.Error())
		}
	}

	expTables := []string{"test0", "test1", "test2", "test3"}
	tableNames, err = GetTableNames()
	if err != nil {
		t.Fatal("Did not expect database error: " + err.Error())
	}

	assert.Equal(t, expTables, tableNames)
}
开发者ID:rzajac,项目名称:goassert,代码行数:30,代码来源:assertmysql_test.go


示例5: Test_ToCsvQoute

func Test_ToCsvQoute(t *testing.T) {
	// Prepare test
	p := &person{"Tom", 45, 111.22, "aaa", true}

	// Start test
	gotCsv := ToCsv(p, "|", "YY", "NN", true)
	assert.Equal(t, "\"Tom\"|\"45\"|\"111.22\"|\"YY\"", gotCsv)
}
开发者ID:Telling,项目名称:csvutil,代码行数:8,代码来源:csvutil_test.go


示例6: Test_NewReader

func Test_NewReader(t *testing.T) {
	// Prepare test
	sr := NewStringReadCloser(strings.Join(testCsvLines, "\n"))
	c := NewCsvUtil(sr).Comma('|').TrailingComma(true).FieldsPerRecord(-1)

	// Start test
	assert.NotNil(t, c.csvr)
	l, err := c.read()
	assert.NotError(t, err)
	assert.Equal(t, []string{"Tony", "23", "123.456", "Y"}, l)
	assert.Equal(t, "Tony|23|123.456|Y", c.LastCsvLine())

	l, err = c.read()
	assert.NotError(t, err)
	assert.Equal(t, []string{"John", "34", "234.567", "N", ""}, l)
	assert.Equal(t, "John|34|234.567|N|", c.LastCsvLine())
}
开发者ID:rzajac,项目名称:csvutil,代码行数:17,代码来源:csvutil_test.go


示例7: Test_ToCsv

func Test_ToCsv(t *testing.T) {
	// Prepare test
	p := &person{"Tom", 45, 111.22, "aaa", true}

	// Start test
	gotCsv := ToCsv(p, "|", "YY", "NN")
	assert.Equal(t, "Tom|45|111.22|YY", gotCsv)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:8,代码来源:csvutil_test.go


示例8: Test_customTrueFalse

func Test_customTrueFalse(t *testing.T) {
	// Prepare test
	sr := NewStringReadCloser("YY|NN")
	c := NewCsvUtil(sr).Comma('|').CustomBool([]string{"YY"}, []string{"NN"})

	type YN struct {
		Yes bool
		No  bool
	}

	// Start test
	p := &YN{}
	err := c.SetData(p)
	assert.NotError(t, err)

	assert.Equal(t, true, p.Yes)
	assert.Equal(t, false, p.No)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:18,代码来源:csvutil_test.go


示例9: Test_Header

func Test_Header(t *testing.T) {
	// Prepare test
	c := NewCsvUtil(nil)

	// Start test
	exp := CsvHeader{"Name": 0, "Age": 1, "Balance": 2, "LowBalance": 3}
	c.Header(exp)
	assert.Equal(t, exp, c.header)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:9,代码来源:csvutil_test.go


示例10: Test_embededToCsv

func Test_embededToCsv(t *testing.T) {
	// Prepare test
	b := new(B)
	b.Field1 = "F1"
	b.Field2 = "F2"
	b.Field3 = "F3"

	// Start test
	assert.Equal(t, "F1,F2,F3", ToCsv(b, ",", "Y", "N"))
}
开发者ID:rzajac,项目名称:csvutil,代码行数:10,代码来源:csvutil_test.go


示例11: Test_embededToCsvQuote

func Test_embededToCsvQuote(t *testing.T) {
	// Prepare test
	b := new(B)
	b.Field1 = "F1"
	b.Field2 = "F2"
	b.Field3 = "F3"

	// Start test
	assert.Equal(t, "\"F1\",\"F2\",\"F3\"", ToCsv(b, ",", "Y", "N", true))
}
开发者ID:Telling,项目名称:csvutil,代码行数:10,代码来源:csvutil_test.go


示例12: Test_getFields

func Test_getFields(t *testing.T) {
	// Prepare test
	p := &person{}

	// Start test
	fields, structName := getFields(p)
	assert.Equal(t, 4, len(fields))
	assert.Equal(t, "csvutil.person", structName)

	assert.Equal(t, "Name", fields[0].name)
	assert.Equal(t, reflect.String, fields[0].typ.Kind())

	assert.Equal(t, "Age", fields[1].name)
	assert.Equal(t, reflect.Int, fields[1].typ.Kind())

	assert.Equal(t, "Balance", fields[2].name)
	assert.Equal(t, reflect.Float32, fields[2].typ.Kind())

	assert.Equal(t, "LowBalance", fields[3].name)
	assert.Equal(t, reflect.Bool, fields[3].typ.Kind())
}
开发者ID:rzajac,项目名称:csvutil,代码行数:21,代码来源:csvutil_test.go


示例13: ErrorCode

// ErrorCode asserts err is *mysql.Error and has code.
// Applicable only to github.com/ziutek/mymysql/mysql package.
func ErrorCode(t assert.Tester, err error, errorCode uint16) {
	assert.Error(t, err, assert.NESTING_2, assert.FAIL_SLOW, "Expected error but got nil.")

	merr := GetMySqlErorr(err)
	fn := func() {
		t.Error("Expected MySQL error but got some other error.")
		if err == nil {
			t.Errorf("Got error: nil")
		} else {
			t.Errorf("Got error: %s", err.Error())
		}
	}
	_, ok := err.(*mysql.Error)
	assert.Assert(t, ok, assert.NESTING_2, assert.FAIL_FAST, fn)
	assert.Equal(t, errorCode, merr.Code, assert.NESTING_2, "Expected error code %d got %d.", errorCode, merr.Code)
}
开发者ID:rzajac,项目名称:goassert,代码行数:18,代码来源:assertmysql.go


示例14: Test_TrailingComma

func Test_TrailingComma(t *testing.T) {
	csvu := NewCsvUtil(nil)
	assert.Equal(t, false, csvu.csvr.TrailingComma)
	csvu.TrailingComma(true)
	assert.Equal(t, true, csvu.csvr.TrailingComma)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:6,代码来源:csvutil_test.go


示例15: TableRowCount

// TableRowCount asserts tableName has expectedRowCount rows.
func TableRowCount(t assert.Tester, tableName string, expectedRowCount int) {
	rowCount, err := GetTableRowCount(tableName)
	assert.NotError(t, err, assert.NESTING_2)
	assert.Equal(t, rowCount, expectedRowCount, assert.NESTING_2, "Expected %d rows in %s table but got %d.", expectedRowCount, tableName, rowCount)
}
开发者ID:rzajac,项目名称:goassert,代码行数:6,代码来源:assertmysql.go


示例16: Test_AssertEqual

func Test_AssertEqual(t *testing.T) {
	p1 := Point{1, 1}
	p2 := Point{2, 1}
	assert.Equal(t, p1, p2)
}
开发者ID:rzajac,项目名称:goassert,代码行数:5,代码来源:assert_examples_test.go


示例17: Test_SetData

func Test_SetData(t *testing.T) {
	// Prepare test
	sr := NewStringReadCloser(strings.Join(testCsvLines, "\n"))
	c := NewCsvUtil(sr).Comma('|').
		TrailingComma(true).
		FieldsPerRecord(-1).
		CustomBool([]string{"Y"}, []string{"N"})

	// Start test
	p := &person{Skipped: "aaa"}
	err := c.SetData(p)
	assert.NotError(t, err)
	assert.Equal(t, "Tony", p.Name)
	assert.Equal(t, 23, p.Age)
	assert.Equal(t, float32(123.456), p.Balance)
	assert.Equal(t, "aaa", p.Skipped)
	assert.Equal(t, true, p.LowBalance)

	err = c.SetData(p)
	assert.NotError(t, err)
	assert.Equal(t, "John", p.Name)
	assert.Equal(t, 34, p.Age)
	assert.Equal(t, float32(234.567), p.Balance)
	assert.Equal(t, "aaa", p.Skipped)
	assert.Equal(t, false, p.LowBalance)

	err = c.SetData(p)
	assert.Equal(t, io.EOF, err)
	// The previous data stays intact
	assert.Equal(t, "John", p.Name)
	assert.Equal(t, 34, p.Age)
	assert.Equal(t, float32(234.567), p.Balance)
	assert.Equal(t, "aaa", p.Skipped)
	assert.Equal(t, false, p.LowBalance)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:35,代码来源:csvutil_test.go


示例18: Test_Comma

func Test_Comma(t *testing.T) {
	csvu := NewCsvUtil(nil)
	assert.Equal(t, ',', csvu.csvr.Comma)
	csvu.Comma('|')
	assert.Equal(t, '|', csvu.csvr.Comma)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:6,代码来源:csvutil_test.go


示例19: TableCount

// TableCount asserts number of tables in the database.
func TableCount(t assert.Tester, expectedCount int) {
	sqlTables, _ := GetTableNames()
	tablesCount := len(sqlTables)
	assert.Equal(t, expectedCount, tablesCount, assert.NESTING_2, "Expected %d tables but got %d.", expectedCount, tablesCount)
}
开发者ID:rzajac,项目名称:goassert,代码行数:6,代码来源:assertmysql.go


示例20: Test_Comment

func Test_Comment(t *testing.T) {
	csvu := NewCsvUtil(nil)
	assert.Equal(t, '\000', csvu.csvr.Comment)
	csvu.Comment('#')
	assert.Equal(t, '#', csvu.csvr.Comment)
}
开发者ID:rzajac,项目名称:csvutil,代码行数:6,代码来源:csvutil_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.Tspy类代码示例发布时间:2022-05-28
下一篇:
Golang columnize.SimpleFormat函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap