Merge branch '8784-dir-listings'
[arvados.git] / sdk / go / stats / duration_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package stats
6
7 import (
8         "testing"
9         "time"
10 )
11
12 func TestString(t *testing.T) {
13         d := Duration(123123123123 * time.Nanosecond)
14         if s, expect := d.String(), "123.123123"; s != expect {
15                 t.Errorf("got %s, expect %s", s, expect)
16         }
17 }
18
19 func TestSet(t *testing.T) {
20         var d Duration
21         if err := d.Set("123.456"); err != nil {
22                 t.Fatal(err)
23         }
24         if got, expect := time.Duration(d).Nanoseconds(), int64(123456000000); got != expect {
25                 t.Errorf("got %d, expect %d", got, expect)
26         }
27 }