当前位置: 首页>>代码示例>>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;未经允许,请勿转载。