1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
11 check "gopkg.in/check.v1"
14 var _ = check.Suite(&DurationSuite{})
16 type DurationSuite struct{}
18 func (s *DurationSuite) TestMarshalJSON(c *check.C) {
22 err := json.Unmarshal([]byte(`{"D":"1.234s"}`), &d)
23 c.Check(err, check.IsNil)
24 c.Check(d.D, check.Equals, Duration(time.Second+234*time.Millisecond))
25 buf, err := json.Marshal(d)
26 c.Check(string(buf), check.Equals, `{"D":"1.234s"}`)
28 for _, trial := range []struct {
39 {360610, "100h10m10s"},
41 buf, err := json.Marshal(Duration(time.Duration(trial.seconds) * time.Second))
42 c.Check(err, check.IsNil)
43 c.Check(string(buf), check.Equals, `"`+trial.out+`"`)