예제 #1
0
파일: box_test.go 프로젝트: jackc/box
func (s *MySuite) TestGetCoerceNil(c *C) {
	var b box.Time

	b.SetUndefined()
	c.Check(b.GetCoerceNil(), Equals, nil)

	b.SetUnknown()
	c.Check(b.GetCoerceNil(), Equals, nil)

	b.SetEmpty()
	c.Check(b.GetCoerceNil(), Equals, nil)

	val := time.Now()
	b.Set(val)
	c.Check(b.GetCoerceNil(), Equals, val)
}
예제 #2
0
파일: box_test.go 프로젝트: jackc/box
func (s *MySuite) TestSetAndGet(c *C) {
	var b box.Time
	val := time.Now()

	b.Set(val)

	val2, present := b.Get()
	c.Check(val2, Equals, val)
	c.Check(present, Equals, true)

	c.Check(b.MustGet(), Equals, val)

	b.SetUndefined()
	_, present = b.Get()
	c.Check(present, Equals, false)

	b.SetUnknown()
	_, present = b.Get()
	c.Check(present, Equals, false)

	b.SetEmpty()
	_, present = b.Get()
	c.Check(present, Equals, false)
}