MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestSafeStringValue

Function TestSafeStringValue

pkg/api/utils_test.go:182–231  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestSafeStringValue(t *testing.T) {
183 tests := []struct {
184 name string
185 input interface{}
186 expected string
187 }{
188 {
189 name: "string input",
190 input: "hello",
191 expected: "hello",
192 },
193 {
194 name: "integer input",
195 input: 123,
196 expected: "123",
197 },
198 {
199 name: "float input",
200 input: 123.45,
201 expected: "123.45",
202 },
203 {
204 name: "boolean true",
205 input: true,
206 expected: "true",
207 },
208 {
209 name: "boolean false",
210 input: false,
211 expected: "false",
212 },
213 {
214 name: "nil input",
215 input: nil,
216 expected: "",
217 },
218 {
219 name: "empty string",
220 input: "",
221 expected: "",
222 },
223 }
224
225 for _, tt := range tests {
226 t.Run(tt.name, func(t *testing.T) {
227 result := SafeStringValue(tt.input)
228 assert.Equal(t, tt.expected, result)
229 })
230 }
231}
232
233func TestSafeFloatValue(t *testing.T) {
234 tests := []struct {

Callers

nothing calls this directly

Calls 2

SafeStringValueFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected