當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。