MCPcopy Index your code
hub / github.com/coder/coder / TestToMicros

Function TestToMicros

scripts/aibridgepricesgen/main_test.go:10–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestToMicros(t *testing.T) {
11 t.Parallel()
12
13 cases := []struct {
14 name string
15 in *float64
16 want *int64
17 }{
18 {"missing", nil, nil},
19 {"zero", floatPtr(0), int64Ptr(0)},
20 {"whole", floatPtr(3), int64Ptr(3_000_000)},
21 {"fractional", floatPtr(0.075), int64Ptr(75_000)},
22 {"negative", floatPtr(-1), nil},
23 }
24
25 for _, tc := range cases {
26 t.Run(tc.name, func(t *testing.T) {
27 t.Parallel()
28 got := toMicros(tc.in)
29 if tc.want == nil {
30 require.Nil(t, got)
31 return
32 }
33 require.NotNil(t, got)
34 require.Equal(t, *tc.want, *got)
35 })
36 }
37}
38
39func TestConvert(t *testing.T) {
40 t.Parallel()

Callers

nothing calls this directly

Calls 5

floatPtrFunction · 0.85
toMicrosFunction · 0.85
int64PtrFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected