MCPcopy
hub / github.com/dropbox/godropbox / TestBuildValuePointer

Method TestBuildValuePointer

database/sqltypes/sqltypes_test.go:275–306  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

273}
274
275func (s *SqlTypesSuite) TestBuildValuePointer(c *C) {
276 // nil pointer
277 var i *int
278 v, err := BuildValue(i)
279 c.Assert(err, IsNil)
280 c.Assert(v.IsNull(), IsTrue)
281
282 var t *time.Time
283 v, err = BuildValue(t)
284 c.Assert(err, IsNil)
285 c.Assert(v.IsNull(), IsTrue)
286
287 // non-nil pointer
288 in := int(-1)
289 var out int
290 v, err = BuildValue(&in)
291 c.Assert(err, IsNil)
292 c.Assert(v.IsNull(), IsFalse)
293 c.Assert(v.IsNumeric(), IsTrue)
294 c.Assert(v.String(), Equals, "-1")
295
296 err = ConvertAssign(v, &out)
297 c.Assert(err, IsNil)
298 c.Assert(out, Equals, in)
299
300 t2 := time.Date(2012, time.February, 24, 23, 19, 43, 10, time.UTC)
301 v, err = BuildValue(&t2)
302 c.Assert(err, IsNil)
303 c.Assert(v.IsNull(), IsFalse)
304 c.Assert(v.IsString(), IsTrue)
305 c.Assert(v.String(), Equals, "2012-02-24 23:19:43.000000")
306}
307
308func TestConvertAssignDefault(t *testing.T) {
309 v, err := BuildValue(3)

Callers

nothing calls this directly

Calls 6

BuildValueFunction · 0.85
ConvertAssignFunction · 0.85
IsNullMethod · 0.80
IsNumericMethod · 0.80
IsStringMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected