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


Golang assert.Equal函数代码示例

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


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


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