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

Function TestAnimalString

example/animal_test.go:18–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16}
17
18func TestAnimalString(t *testing.T) {
19 x := Animal(109)
20 assert.Equal(t, "Animal(109)", x.String())
21 x = Animal(1)
22 assert.Equal(t, "Dog", x.String())
23
24 y, err := ParseAnimal("Cat")
25 require.NoError(t, err, "Failed parsing cat")
26 assert.Equal(t, AnimalCat, y)
27
28 z, err := ParseAnimal("Snake")
29 require.Error(t, err, "Shouldn't parse a snake")
30 assert.Equal(t, Animal(0), z)
31}
32
33func TestAnimalUnmarshal(t *testing.T) {
34 tests := []struct {

Callers

nothing calls this directly

Calls 3

ParseAnimalFunction · 0.85
AnimalTypeAlias · 0.70
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…