MCPcopy Index your code
hub / github.com/google/go-github / TestStringify

Function TestStringify

github/strings_test.go:14–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestStringify(t *testing.T) {
15 t.Parallel()
16 var nilPointer *string
17
18 tests := []struct {
19 in any
20 out string
21 }{
22 // basic types
23 {"foo", `"foo"`},
24 {123, `123`},
25 {1.5, `1.5`},
26 {false, `false`},
27 {
28 []string{"a", "b"},
29 `["a" "b"]`,
30 },
31 {
32 struct {
33 A []string
34 }{nil},
35 // nil slice is skipped
36 `{}`,
37 },
38 {
39 struct {
40 A string
41 }{"foo"},
42 // structs not of a named type get no prefix
43 `{A:"foo"}`,
44 },
45
46 // pointers
47 {nilPointer, `<nil>`},
48 {Ptr("foo"), `"foo"`},
49 {Ptr(123), `123`},
50 {Ptr(false), `false`},
51 {
52 //nolint:sliceofpointers
53 []*string{Ptr("a"), Ptr("b")},
54 `["a" "b"]`,
55 },
56
57 // actual GitHub structs
58 {
59 Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)},
60 `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`,
61 },
62 {
63 &Timestamp{time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC)},
64 `github.Timestamp{2006-01-02 15:04:05 +0000 UTC}`,
65 },
66 {
67 User{ID: Ptr(int64(123)), Name: Ptr("n")},
68 `github.User{ID:123, Name:"n"}`,
69 },
70 {
71 Repository{Owner: &User{ID: Ptr(int64(123))}},

Callers

nothing calls this directly

Calls 2

StringifyFunction · 0.85
PtrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…