D Duration
}
err := json.Unmarshal([]byte(`{"D":1.234}`), &d)
- c.Check(err, check.ErrorMatches, `missing unit in duration 1.234`)
+ c.Check(err, check.ErrorMatches, `.*missing unit in duration "?1\.234"?`)
err = json.Unmarshal([]byte(`{"D":"1.234"}`), &d)
- c.Check(err, check.ErrorMatches, `.*missing unit in duration 1.234`)
+ c.Check(err, check.ErrorMatches, `.*missing unit in duration "?1\.234"?`)
err = json.Unmarshal([]byte(`{"D":"1"}`), &d)
- c.Check(err, check.ErrorMatches, `.*missing unit in duration 1`)
+ c.Check(err, check.ErrorMatches, `.*missing unit in duration "?1"?`)
err = json.Unmarshal([]byte(`{"D":"foobar"}`), &d)
- c.Check(err, check.ErrorMatches, `.*invalid duration foobar`)
+ c.Check(err, check.ErrorMatches, `.*invalid duration "?foobar"?`)
err = json.Unmarshal([]byte(`{"D":"60s"}`), &d)
c.Check(err, check.IsNil)
c.Check(d.D.Duration(), check.Equals, time.Minute)
+
+ d.D = Duration(time.Second)
+ err = json.Unmarshal([]byte(`{"D":"0"}`), &d)
+ c.Check(err, check.IsNil)
+ c.Check(d.D.Duration(), check.Equals, time.Duration(0))
+
+ d.D = Duration(time.Second)
+ err = json.Unmarshal([]byte(`{"D":0}`), &d)
+ c.Check(err, check.IsNil)
+ c.Check(d.D.Duration(), check.Equals, time.Duration(0))
}