MCPcopy Create free account
hub / github.com/abice/go-enum / TestSQLIntExtras

Function TestSQLIntExtras

example/sql_int_enum_test.go:371–479  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

369}
370
371func TestSQLIntExtras(t *testing.T) {
372 assert.Equal(t, "ImageType(22)", ImageType(22).String(), "String value is not correct")
373
374 _, err := ParseImageType(`NotAStatus`)
375 assert.Error(t, err, "Should have had an error parsing a non status")
376
377 var (
378 intVal int = 3
379 strVal string = "png"
380 enumVal ImageType = ImageTypeGif
381 nullInt *int
382 nullInt64 *int64
383 nullUint *uint
384 nullUint64 *uint64
385 nullString *string
386 nullImageType *ImageType
387 )
388
389 tests := map[string]struct {
390 input interface{}
391 result NullImageType
392 }{
393 "nil": {},
394 "val": {
395 input: ImageTypeTiff,
396 result: NullImageType{
397 ImageType: ImageTypeTiff,
398 Valid: true,
399 },
400 },
401 "ptr": {
402 input: &enumVal,
403 result: NullImageType{
404 ImageType: ImageTypeGif,
405 Valid: true,
406 },
407 },
408 "string": {
409 input: strVal,
410 result: NullImageType{
411 ImageType: ImageTypePng,
412 Valid: true,
413 },
414 },
415 "*string": {
416 input: &strVal,
417 result: NullImageType{
418 ImageType: ImageTypePng,
419 Valid: true,
420 },
421 },
422 "invalid string": {
423 input: "random value",
424 },
425 "[]byte": {
426 input: []byte(ImageTypeGif.String()),
427 result: NullImageType{
428 ImageType: ImageTypeGif,

Callers

nothing calls this directly

Calls 4

ImageTypeTypeAlias · 0.85
ParseImageTypeFunction · 0.85
NewNullImageTypeFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…