From 5d99e697aab03fb552a6536710c521c83fc65234 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 22 Nov 2021 13:22:14 +0300 Subject: [PATCH] [#356] refs: Test text marshaling of nil SubnetID Add `(*refs.SubnetID)(nil).MarshalText()` unit test. Signed-off-by: Leonard Lyubich --- refs/types_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/refs/types_test.go b/refs/types_test.go index 52c6b80c..e2077b2b 100644 --- a/refs/types_test.go +++ b/refs/types_test.go @@ -35,6 +35,18 @@ func TestSubnetID_MarshalText(t *testing.T) { require.NoError(t, err) require.EqualValues(t, val, res) + + t.Run("nil", func(t *testing.T) { + var id *refs.SubnetID + + txt, err := id.MarshalText() + require.NoError(t, err) + + res, err := strconv.ParseUint(string(txt), 10, 32) + require.NoError(t, err) + + require.Zero(t, res) + }) } func TestSubnetID_UnmarshalText(t *testing.T) {