Example #1
0
func (s *MySuite) TestSetCoerceZero(c *C) {
	var b box.Time
	var zero time.Time

	b.SetCoerceZero(zero, box.Empty)
	c.Check(b.Status(), Equals, byte(box.Empty))
}
Example #2
0
func (s *MySuite) TestSetCoerceNil(c *C) {
	var b box.Time

	b.SetCoerceNil(nil, box.Empty)

	c.Check(b.Status(), Equals, byte(box.Empty))
}
Example #3
0
func (s *MySuite) TestMustGetPanicsWhenNotFull(c *C) {
	var b box.Time

	b.SetUndefined()
	c.Check(b.MustGet, Panics, "called MustGet on a box that was not full")

	b.SetUnknown()
	c.Check(b.MustGet, Panics, "called MustGet on a box that was not full")

	b.SetEmpty()
	c.Check(b.MustGet, Panics, "called MustGet on a box that was not full")
}
Example #4
0
func (s *MySuite) TestGetCoerceZero(c *C) {
	var b box.Time
	var zero time.Time

	b.SetUndefined()
	c.Check(b.GetCoerceZero(), Equals, zero)

	b.SetUnknown()
	c.Check(b.GetCoerceZero(), Equals, zero)

	b.SetEmpty()
	c.Check(b.GetCoerceZero(), Equals, zero)

	val := time.Now()
	b.Set(val)
	c.Check(b.GetCoerceNil(), Equals, val)
}
Example #5
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)
}
Example #6
0
func (s *MySuite) TestZeroValueTimeIsUndefined(c *C) {
	var b box.Time
	c.Check(b.Status(), Equals, byte(box.Undefined))
}