(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestNormalizedEnumValue(t *testing.T) { |
| 41 | t.Parallel() |
| 42 | |
| 43 | tests := []struct { |
| 44 | name string |
| 45 | value string |
| 46 | allowed []string |
| 47 | want *string |
| 48 | }{ |
| 49 | { |
| 50 | name: "MatchFound", |
| 51 | value: "medium", |
| 52 | allowed: []string{"Low", "Medium", "High"}, |
| 53 | want: ptr("Medium"), |
| 54 | }, |
| 55 | { |
| 56 | name: "MatchMissing", |
| 57 | value: "maximum", |
| 58 | allowed: []string{"Low", "Medium", "High"}, |
| 59 | }, |
| 60 | } |
| 61 | |
| 62 | for _, tt := range tests { |
| 63 | t.Run(tt.name, func(t *testing.T) { |
| 64 | t.Parallel() |
| 65 | |
| 66 | got := chatutil.NormalizedEnumValue(tt.value, tt.allowed...) |
| 67 | if tt.want == nil { |
| 68 | require.Nil(t, got) |
| 69 | return |
| 70 | } |
| 71 | require.NotNil(t, got) |
| 72 | require.Equal(t, *tt.want, *got) |
| 73 | }) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | func ptr[T any](value T) *T { |
| 78 | return &value |
nothing calls this directly
no test coverage detected