Esempio n. 1
0
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)
}
Esempio n. 2
0
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)
}