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

Function TestParseIntValue

pkg/workflow/map_helpers_test.go:11–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestParseIntValue(t *testing.T) {
12 tests := []struct {
13 name string
14 value any
15 expected int
16 ok bool
17 }{
18 {
19 name: "int value",
20 value: 42,
21 expected: 42,
22 ok: true,
23 },
24 {
25 name: "int64 value",
26 value: int64(100),
27 expected: 100,
28 ok: true,
29 },
30 {
31 name: "uint64 value",
32 value: uint64(200),
33 expected: 200,
34 ok: true,
35 },
36 {
37 name: "float64 value",
38 value: float64(3.14),
39 expected: 3,
40 ok: true,
41 },
42 {
43 name: "string value (not supported)",
44 value: "42",
45 expected: 0,
46 ok: false,
47 },
48 {
49 name: "nil value",
50 value: nil,
51 expected: 0,
52 ok: false,
53 },
54 {
55 name: "bool value (not supported)",
56 value: true,
57 expected: 0,
58 ok: false,
59 },
60 }
61
62 for _, tt := range tests {
63 t.Run(tt.name, func(t *testing.T) {
64 result, ok := typeutil.ParseIntValue(tt.value)
65 if ok != tt.ok {
66 t.Errorf("typeutil.ParseIntValue() ok = %v, want %v", ok, tt.ok)
67 }
68 if result != tt.expected {

Callers

nothing calls this directly

Calls 3

ParseIntValueFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected