Beispiel #1
0
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)
}
Beispiel #2
0
func TestFileType(t *testing.T) {
	testing2.Eq(t, true, IsGoFile("aa.go"))
	testing2.Eq(t, true, IsSrcFile("aa.go"))
	testing2.Eq(t, true, IsTestFile("aa_test.go"))
	testing2.Eq(t, false, IsSrcFile("aa_test.go"))
	testing2.Eq(t, "aa_test.go", SrcTestFile("aa.go"))
}
Beispiel #3
0
func TestHex2Uint(t *testing.T) {
	res, _ := Hex2Uint("0XAff")
	testing2.Eq(t, uint64(0xaff), res)

	res, err := Hex2Uint("0xzz")
	testing2.True(t, err != nil)

	res, _ = Hex2Uint("00fff")
	testing2.Eq(t, uint64(0xfff), res)
}
Beispiel #4
0
func TestStringIn(t *testing.T) {
	testing2.Eq(t, 1, StringIn("b", []string{"a", "b", "c"}))
	testing2.Eq(t, 0, StringIn("a", []string{"a", "b", "c"}))
	testing2.Eq(t, -1, StringIn("d", []string{"a", "b", "c"}))
}
Beispiel #5
0
func TestBytes(t *testing.T) {
	testing2.Eq(t, true, bytes.Equal([]byte("abcde"), Bytes("abcde")))
}
Beispiel #6
0
func TestString(t *testing.T) {
	testing2.Eq(t, "abcde", String([]byte("abcde")))
}