From 7a1d2f00367b84b5d8e830b361ead22cd473d711 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 5 Sep 2024 16:03:01 +0200 Subject: [PATCH] Test types.NotificationTypes#Value() --- pkg/icingadb/types/notification_types_test.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/icingadb/types/notification_types_test.go b/pkg/icingadb/types/notification_types_test.go index 022568fe..b32f984c 100644 --- a/pkg/icingadb/types/notification_types_test.go +++ b/pkg/icingadb/types/notification_types_test.go @@ -32,3 +32,27 @@ func TestNotificationTypes_UnmarshalJSON(t *testing.T) { }) } } + +func TestNotificationTypes_Value(t *testing.T) { + subtests := []struct { + name string + io NotificationTypes + error bool + }{ + {name: "out-of-range", io: ^NotificationTypes(0), error: true}, + {name: "empty", io: 0}, + {name: "single", io: 32}, + {name: "multiple", io: 48}, + } + + for _, st := range subtests { + t.Run(st.name, func(t *testing.T) { + if v, err := st.io.Value(); st.error { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, int64(st.io), v) + } + }) + } +}