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") }
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) }
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) }