Exemple #1
0
func (s *CheckersS) TestCompare(c *check.C) {
	c.Assert(10, check.Less, 11)
	c.Assert(10, check.LessEqual, 10)
	c.Assert(10, check.Greater, 9)
	c.Assert(10, check.GreaterEqual, 10)
	c.Assert(10, check.Not(check.LessEqual), 9)
	c.Assert(10, check.Not(check.Less), 9)
	c.Assert("ABC", check.Less, "ABCD")
	c.Assert([]byte("ABC"), check.Less, []byte("ABCD"))
	c.Assert(3.14, check.Less, 3.145)
}
Exemple #2
0
func (s *CheckersS) TestCompare(c *check.C) {
	c.Assert(10, check.Less, 11)
	c.Assert(10, check.LessEqual, 10)
	c.Assert(10, check.Greater, 9)
	c.Assert(10, check.GreaterEqual, 10)
	c.Assert(10, check.Not(check.LessEqual), 9)
	c.Assert(10, check.Not(check.Less), 9)
	c.Assert("ABC", check.Less, "ABCD")
	c.Assert([]byte("ABC"), check.Less, []byte("ABCD"))
	c.Assert(3.14, check.Less, 3.145)
	c.Assert(time.Duration(1), check.Greater, time.Duration(0))
	c.Assert(time.Now(), check.Less, time.Now().Add(10*time.Second))
}
Exemple #3
0
func (s *HelpersS) TestMkDir(c *check.C) {
	helper := MkDirHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output})
	c.Assert(output.value, check.Equals, "")
	c.Check(helper.isDir1, check.Equals, true)
	c.Check(helper.isDir2, check.Equals, true)
	c.Check(helper.isDir3, check.Equals, true)
	c.Check(helper.isDir4, check.Equals, true)
	c.Check(helper.path1, check.Not(check.Equals),
		helper.path2)
	c.Check(isDir(helper.path1), check.Equals, false)
	c.Check(isDir(helper.path2), check.Equals, false)
}
Exemple #4
0
	if !(ok1 && ok2) {
		return false, "Arguments to IsError must both be errors"
	}

	return ErrorEqual(b1, b2), ""
}

func (e *isError) Info() *check.CheckerInfo {
	return &check.CheckerInfo{
		Name:   "IsError",
		Params: []string{"error_one", "error_two"},
	}
}

// IsError checker checks whether err1 is the same as err2 in test using gocheck.
//
// For example:
//
//     c.Assert(err1, terror.IsError, err2)
//
var IsError = &isError{}

// IsNotError checker checks whether err1 is not the same as err2 in test using gocheck.
//
// For example:
//
//     c.Assert(err1, terror.IsNotError, err2)
//
var IsNotError = check.Not(IsError)
Exemple #5
0
func (s *CheckersS) TestNot(c *check.C) {
	testInfo(c, check.Not(check.IsNil), "Not(IsNil)", []string{"value"})

	testCheck(c, check.Not(check.IsNil), false, "", nil)
	testCheck(c, check.Not(check.IsNil), true, "", "a")
}
Exemple #6
0
func (s *CheckersS) TestBytes(c *check.C) {
	c.Assert([]byte{0x00}, check.BytesEquals, []byte{0x00})
	c.Assert([]byte{0x00}, check.Not(check.BytesEquals), []byte{0x01})
}