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

Function TestNegativeString

example/negative_test.go:55–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestNegativeString(t *testing.T) {
56 tests := map[string]struct {
57 input string
58 output AllNegative
59 }{
60 "unknown": {
61 input: `Unknown`,
62 output: AllNegativeUnknown,
63 },
64 "good": {
65 input: `Good`,
66 output: AllNegativeGood,
67 },
68 "bad": {
69 input: `Bad`,
70 output: AllNegativeBad,
71 },
72 "ugly": {
73 input: `Ugly`,
74 output: AllNegativeUgly,
75 },
76 }
77
78 for name, tc := range tests {
79 t.Run(name, func(t *testing.T) {
80 output, err := ParseAllNegative(tc.input)
81 assert.NoError(t, err)
82 assert.Equal(t, tc.output, output)
83
84 assert.Equal(t, tc.input, output.String())
85 })
86 }
87
88 t.Run("failures", func(t *testing.T) {
89 assert.Equal(t, "AllNegative(99)", AllNegative(99).String())
90 allN, err := ParseAllNegative("")
91 assert.Error(t, err)
92
93 assert.Equal(t, AllNegative(0), allN)
94 })
95 t.Run("cased", func(t *testing.T) {
96 actual, err := ParseAllNegative("UGLY")
97 assert.NoError(t, err)
98 assert.Equal(t, AllNegativeUgly, actual)
99 })
100}

Callers

nothing calls this directly

Calls 3

ParseAllNegativeFunction · 0.85
AllNegativeTypeAlias · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…