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

Function TestFormatFieldValue_Pointers

pkg/console/render_formatting_test.go:11–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestFormatFieldValue_Pointers(t *testing.T) {
12 tests := []struct {
13 name string
14 value any
15 expected string
16 }{
17 {
18 name: "nil pointer",
19 value: (*int)(nil),
20 expected: "-",
21 },
22 {
23 name: "single pointer to int",
24 value: func() *int {
25 v := 42
26 return &v
27 }(),
28 expected: "42",
29 },
30 {
31 name: "double pointer to int",
32 value: func() **int {
33 v := 42
34 p1 := &v
35 return &p1
36 }(),
37 expected: "42",
38 },
39 }
40
41 for _, tt := range tests {
42 t.Run(tt.name, func(t *testing.T) {
43 val := reflect.ValueOf(tt.value)
44 result := formatFieldValue(val)
45 if result != tt.expected {
46 t.Errorf("got %q, want %q", result, tt.expected)
47 }
48 })
49 }
50}
51
52func TestFormatFieldValue_NumericTypes(t *testing.T) {
53 tests := []struct {

Callers

nothing calls this directly

Calls 3

formatFieldValueFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected