MCPcopy Create free account
hub / github.com/github/gh-aw / TestParseOptionalInt

Function TestParseOptionalInt

pkg/workflow/cache_optional_int_test.go:14–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestParseOptionalInt(t *testing.T) {
15 t.Run("integer float is accepted", func(t *testing.T) {
16 value := parseOptionalInt(7.0)
17 require.NotNil(t, value)
18 assert.Equal(t, 7, *value)
19 })
20
21 t.Run("fractional float is rejected", func(t *testing.T) {
22 assert.Nil(t, parseOptionalInt(7.5))
23 })
24
25 t.Run("nan and infinity are rejected", func(t *testing.T) {
26 assert.Nil(t, parseOptionalInt(math.NaN()))
27 assert.Nil(t, parseOptionalInt(math.Inf(1)))
28 })
29
30 t.Run("uint64 above max int is rejected", func(t *testing.T) {
31 assert.Nil(t, parseOptionalInt(uint64(math.MaxInt)+1))
32 })
33
34 t.Run("large exact float is architecture aware", func(t *testing.T) {
35 value := parseOptionalInt(1e12)
36 if strconv.IntSize == 32 {
37 assert.Nil(t, value)
38 return
39 }
40 require.NotNil(t, value)
41 assert.Equal(t, 1000000000000, *value)
42 })
43}

Callers

nothing calls this directly

Calls 2

parseOptionalIntFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected