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

Function TestStatusString

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

Source from the content-addressed store, hash-verified

10)
11
12func TestStatusString(t *testing.T) {
13 tests := map[string]struct {
14 input string
15 output Status
16 }{
17 "bad": {
18 input: `Bad`,
19 output: StatusBad,
20 },
21 "unknown": {
22 input: `Unknown`,
23 output: StatusUnknown,
24 },
25 "good": {
26 input: `Good`,
27 output: StatusGood,
28 },
29 }
30
31 for name, tc := range tests {
32 t.Run(name, func(t *testing.T) {
33 output, err := ParseStatus(tc.input)
34 assert.NoError(t, err)
35 assert.Equal(t, tc.output, output)
36
37 assert.Equal(t, tc.input, output.String())
38 })
39 }
40
41 t.Run("failures", func(t *testing.T) {
42 assert.Equal(t, "Status(99)", Status(99).String())
43 failedStatus, err := ParseStatus("")
44 assert.Error(t, err)
45
46 assert.Equal(t, Status(0), failedStatus)
47 t.Run("cased", func(t *testing.T) {
48 actual, err := ParseStatus("BAD")
49 assert.NoError(t, err)
50 assert.Equal(t, StatusBad, actual)
51 })
52 })
53}
54
55func TestNegativeString(t *testing.T) {
56 tests := map[string]struct {

Callers

nothing calls this directly

Calls 3

ParseStatusFunction · 0.85
StatusTypeAlias · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…