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

Function TestSpec_PublicAPI_ParseVersionValue

pkg/stringutil/spec_test.go:108–143  ·  view source on GitHub ↗

TestSpec_PublicAPI_ParseVersionValue validates the documented behavior of ParseVersionValue as described in the package README.md. Specification examples: stringutil.ParseVersionValue("20") // "20" stringutil.ParseVersionValue(20) // "20" stringutil.ParseVersionValue(20.0) // "20" S

(t *testing.T)

Source from the content-addressed store, hash-verified

106//
107// Spec also states: "Returns an empty string for nil."
108func TestSpec_PublicAPI_ParseVersionValue(t *testing.T) {
109 tests := []struct {
110 name string
111 input any
112 expected string
113 }{
114 {
115 name: "string input '20' returns '20' (documented example)",
116 input: "20",
117 expected: "20",
118 },
119 {
120 name: "int input 20 returns '20' (documented example)",
121 input: 20,
122 expected: "20",
123 },
124 {
125 name: "float64 input 20.0 returns '20' (documented example)",
126 input: 20.0,
127 expected: "20",
128 },
129 {
130 name: "nil input returns empty string (documented)",
131 input: nil,
132 expected: "",
133 },
134 }
135
136 for _, tt := range tests {
137 t.Run(tt.name, func(t *testing.T) {
138 result := ParseVersionValue(tt.input)
139 assert.Equal(t, tt.expected, result,
140 "ParseVersionValue(%v) should match documented output", tt.input)
141 })
142 }
143}
144
145// TestSpec_PublicAPI_IsPositiveInteger validates the documented behavior of
146// IsPositiveInteger as described in the package README.md.

Callers

nothing calls this directly

Calls 2

ParseVersionValueFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected