當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testing2.Expect函數代碼示例

本文整理匯總了Golang中github.com/cosiner/gohper/testing2.Expect函數的典型用法代碼示例。如果您正苦於以下問題:Golang Expect函數的具體用法?Golang Expect怎麽用?Golang Expect使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Expect函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestJoin

func TestJoin(t *testing.T) {
	testing2.
		Expect("abc,abc,abc").Arg("abc", ",", 3).
		Expect("abc,abc").Arg("abc", ",", 2).
		Expect("abc").Arg("abc", ",", 1).
		Expect("").Arg("abc", ",", 0).
		Run(t, RepeatJoin)

	testing2.
		Expect("").Arg([]int{}, ",").
		Expect("1,2,3,4").Arg([]int{1, 2, 3, 4}, ",").
		Run(t, JoinInt)

	testing2.
		Expect("").Arg([]uint{}, ",").
		Expect("1,2,3,4").Arg([]uint{1, 2, 3, 4}, ",").
		Run(t, JoinUint)

	testing2.
		Expect("").Arg([]string{}, "=?", ", ").
		Expect("a=?").Arg([]string{"a"}, "=?", ", ").
		Expect("a=?, b=?, c=?").Arg([]string{"a", "b", "c"}, "=?", ", ").
		Run(t, SuffixJoin)

}
開發者ID:snowsnail,項目名稱:gohper,代碼行數:25,代碼來源:string_test.go

示例2: TestCols

func TestCols(t *testing.T) {
	var cols Cols = &cols{cols: []string{"id", "age", "name"}}

	testing2.Eq(t, 3, cols.Length())
	testing2.
		Expect("?,?,?").Arg(cols.OnlyParam()).
		Expect("id,age,name").Arg(cols.String()).
		Expect("id=?,age=?,name=?").Arg(cols.Paramed()).
		Run(t, strings2.RemoveSpace)

	cols = singleCol("id")
	testing2.Eq(t, 1, cols.Length())
	testing2.
		Expect("?").Arg(cols.OnlyParam()).
		Expect("id").Arg(cols.String()).
		Expect("id=?").Arg(cols.Paramed()).
		Run(t, strings2.RemoveSpace)

	cols = _emptyCols
	testing2.Eq(t, 0, cols.Length())
	testing2.
		Expect("").Arg(cols.OnlyParam()).
		Expect("").Arg(cols.String()).
		Expect("").Arg(cols.Paramed()).
		Run(t, strings2.RemoveSpace)
}
開發者ID:zj8487,項目名稱:gomodel,代碼行數:26,代碼來源:gomodel_test.go

示例3: testPager

func testPager(p *Pager, t *testing.T) {
	testing2.
		Expect(p.BeginIndex).Arg("abcde").
		Expect(p.BeginIndex).Arg("").
		Expect(p.BeginIndex).Arg("-1").
		Expect(p.BeginIndex).Arg("0").
		Expect(p.BeginIndex).Arg("1").
		Expect(p.PageSize).Arg("2").
		Expect(p.PageSize*2).Arg("3").
		Run(t, p.BeginByString)

	testing2.
		Expect(p.PageSize).Arg("abcde").
		Expect(p.PageSize).Arg("").
		Expect(p.PageSize).Arg("-1").
		Expect(p.PageSize).Arg("0").
		Expect(p.PageSize).Arg("1").
		Expect(p.PageSize*2).Arg("2").
		Expect(p.PageSize*3).Arg("3").
		Run(t, p.EndByString)

	testing2.
		Expect(p.PageSize).Arg(-1).
		Expect(p.PageSize).Arg(0).
		Expect(p.PageSize).Arg(1).
		Expect(p.PageSize*2).Arg(2).
		Expect(p.PageSize*3).Arg(3).
		Run(t, p.End)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:29,代碼來源:pager_test.go

示例4: TestAbridgeString

func TestAbridgeString(t *testing.T) {
	testing2.
		Expect("ABC").Arg("AaaBbbCcc").
		Expect("ABC").Arg("AaaBbbCcc").
		Expect("").Arg("").
		Run(t, ToAbridge)

	testing2.
		Expect("abc").Arg("AaaBbbCcc").
		Expect("abc").Arg("AaaBbbCcc").
		Expect("").Arg("").
		Run(t, ToLowerAbridge)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:13,代碼來源:string_test.go

示例5: TestNumMatched

func TestNumMatched(t *testing.T) {
	testing2.
		Expect(0).Arg(IsNotEmpty, "", "", "", "").
		Expect(1).Arg(IsNotEmpty, "1", "", "", "").
		Expect(2).Arg(IsNotEmpty, "1", "2", "", "").
		Run(t, NumMatched)

	testing2.
		Expect(4).Arg(IsEmpty, "", "", "", "").
		Expect(3).Arg(IsEmpty, "1", "", "", "").
		Expect(2).Arg(IsEmpty, "1", "2", "", "").
		Run(t, NumMatched)
}
開發者ID:snowsnail,項目名稱:gohper,代碼行數:13,代碼來源:string_test.go

示例6: TestMidSep

func TestMidSep(t *testing.T) {
	testing2.
		Expect(-1).Arg("123", byte('1')).
		Expect(-1).Arg("123", byte('3')).
		Expect(-1).Arg("123", byte('4')).
		Expect(1).Arg("123", byte('2')).
		Run(t, MidIndex)

	testing2.
		Expect("", "").Arg("123", byte('1')).
		Expect("", "").Arg("123", byte('3')).
		Expect("", "").Arg("123", byte('4')).
		Expect("1", "3").Arg("123", byte('2')).
		Run(t, Separate)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:15,代碼來源:string_test.go

示例7: TestSplitAtN

func TestSplitAtN(t *testing.T) {
	testing2.
		Expect(3).Arg("123123123", "12", 2).
		Expect(6).Arg("123123123", "12", 3).
		Expect(-1).Arg("123123123", "12", 4).
		Run(t, IndexN)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:7,代碼來源:string_test.go

示例8: TestRemoveSpace

func TestRemoveSpace(t *testing.T) {
	testing2.
		Expect("abcdefg").Arg(`a b
    	c d 	e
    	 	f g`).
		Run(t, RemoveSpace)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:7,代碼來源:string_test.go

示例9: TestTrimQuote

func TestTrimQuote(t *testing.T) {
	testing2.
		Expect("aaa", true).Arg("\"aaa\"").
		Expect("aaa", true).Arg("'aaa'").
		Expect("aaa", true).Arg("`aaa`").
		Expect("", testing2.NonNil).Arg("`aaa").
		Run(t, TrimQuote)
}
開發者ID:amphisbe,項目名稱:gohper,代碼行數:8,代碼來源:string_test.go

示例10: TestIndexNonSpace

func TestIndexNonSpace(t *testing.T) {
	testing2.
		Expect(1).Arg(" 1             ").
		Expect(-1).Arg("             ").
		Expect(0).Arg("a   ").
		Run(t, IndexNonSpace).
		Run(t, LastIndexNonSpace)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:8,代碼來源:string_test.go

示例11: TestCompare

func TestCompare(t *testing.T) {
	testing2.
		Expect(1).Arg("123", "012").
		Expect(-1).Arg("123", "212").
		Expect(0).Arg("123", "123").
		Expect(-1).Arg("123", "1234").
		Expect(1).Arg("123", "12").
		Run(t, Compare)
}
開發者ID:snowsnail,項目名稱:gohper,代碼行數:9,代碼來源:string_test.go

示例12: TestSnakeCase

func TestSnakeCase(t *testing.T) {
	testing2.
		Expect("_xy_xy").Arg("_xy_xy").
		Expect("_xy_xy").Arg("_xy_xy").
		Expect("_xy_xy").Arg("_xyXy").
		Expect("_xy xy").Arg("_Xy Xy").
		Expect("_xy_xy").Arg("_Xy_Xy").
		Run(t, ToSnake)
}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:9,代碼來源:string_test.go

示例13: TestUser

func TestUser(t *testing.T) {
	tt := testing2.Wrap(t)

	u1 := User{
		Name: "User1",
		Age:  20,
	}
	tt.Nil(u1.Add()) // add user1

	u2 := u1 // duplicate user name
	tt.Eq(ErrDuplicateUserName, u2.Add())
	u2.Name = "User2"
	tt.Nil(u2.Add()) // add user2

	f1 := Follow{
		UserId:       u1.Id,
		FollowUserId: 1024000, // user id doesn't exists
	}
	tt.Eq(ErrNoUser, f1.Add())
	f1.FollowUserId = u2.Id
	tt.Nil(f1.Add()) // user1 follow user2

	f2 := Follow{
		UserId:       u2.Id,
		FollowUserId: u1.Id,
	}

	tt.
		Nil(f2.Add()). // user2 follow user1
		Eq(ErrFollowed, f2.Add())

	tt.
		Nil(u1.ById()). // query latest user1 info
		Eq(1, u1.Followers).
		Eq(1, u1.Followings).
		Nil(u2.ById()). // query latest user2 info
		Eq(1, u2.Followers).
		Eq(1, u2.Followings)

	tt.
		Nil(f1.Delete()). // delete follow relationships
		Nil(f2.Delete())

	tt.
		Nil(u1.ById()). // query latest user1 info
		Eq(0, u1.Followings).
		Eq(0, u1.Followings).
		Nil(u2.ById()). // query latest user2 info
		Eq(0, u2.Followings).
		Eq(0, u2.Followings)

	testing2.
		Expect(nil).Arg(u1.Id). // delete user1, user2
		Expect(nil).Arg(u2.Id).
		Run(t, DeleteUserById)
}
開發者ID:shyrobbiani,項目名稱:gomodel,代碼行數:56,代碼來源:example_test.go

示例14: TestParseHuman

func TestParseHuman(t *testing.T) {
	testing2.
		Expect(time.Hour, nil).Arg("1H").
		Expect(time.Minute, nil).Arg("1M").
		Expect(time.Second, nil).Arg("1S").
		Expect(time.Millisecond, nil).Arg("1m").
		Expect(time.Microsecond, nil).Arg("1u").
		Expect(time.Nanosecond, nil).Arg("1n").
		Expect(time.Duration(0), testing2.NonNil).Arg("1z").
		Run(t, ParseHuman)
}
開發者ID:treejames,項目名稱:gohper,代碼行數:11,代碼來源:time_test.go

示例15: TestIn

func TestIn(t *testing.T) {
	tt := testing2.Wrap(t)

	tt.Eq(1, StringIn("b", []string{"a", "b", "c"}))
	tt.Eq(0, StringIn("a", []string{"a", "b", "c"}))
	tt.Eq(-1, StringIn("d", []string{"a", "b", "c"}))

	tt.Eq(0, CharIn('a', "abc"))
	tt.Eq(1, CharIn('b', "abc"))
	tt.Eq(2, CharIn('d', "abd"))
	tt.Eq(-1, CharIn('e', "abcd"))

	testing2.
		Expect(uint(0)).Arg(-1, uint(1<<0|1<<2)).
		Expect(uint(0)).Arg(8, uint(1<<0|1<<2)).
		Expect(uint(0)).Arg(1, uint(1<<0|1<<2)).
		Expect(uint(1<<1)).Arg(1, uint(1<<1|1<<2|1<<3)).
		Expect(uint(1<<2)).Arg(2, uint(1<<2|1<<2|1<<3)).
		Run(t, BitIn)

	testing2.
		Expect(uint(0)).Arg(-1, uint(1<<0|1<<2)).
		Expect(uint(0)).Arg(2, uint(1<<0|1<<2)).
		Expect(uint(1<<9)).Arg(9, uint(1<<0|1<<2)).
		Expect(uint(1<<5)).Arg(5, uint(1<<1|1<<2|1<<3)).
		Expect(uint(1<<8)).Arg(8, uint(1<<2|1<<2|1<<3)).
		Run(t, BitNotIn)

	tt.Eq(2, ByteIn('A', 'B', 'C', 'A'))
	tt.Eq(0, ByteIn('A', 'A', 'B', 'C', 'A'))
	tt.Eq(-1, ByteIn('A', 'B', 'C'))

	tt.Eq(2, SortedNumberIn('C', 'A', 'B', 'C'))
	tt.Eq(0, SortedNumberIn('A', 'A', 'B', 'C', 'D'))
	tt.Eq(-1, SortedNumberIn('A', 'B', 'C'))

	tt.Eq(3, RuneIn('界', '你', '好', '世', '界'))
	tt.Eq(0, RuneIn('你', '你', '好', '世', '界'))
	tt.Eq(-1, RuneIn('是', '你', '好', '世', '界'))

}
開發者ID:sshitaime,項目名稱:gohper,代碼行數:41,代碼來源:index_test.go


注:本文中的github.com/cosiner/gohper/testing2.Expect函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。