From c7a8aa113a914e70e027fea93265c7232b865b5e Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Fri, 7 Jun 2024 19:33:07 +0200 Subject: feat: Add compression --- pkg/u/list_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'pkg/u/list_test.go') diff --git a/pkg/u/list_test.go b/pkg/u/list_test.go index a6d84c7..805a209 100644 --- a/pkg/u/list_test.go +++ b/pkg/u/list_test.go @@ -94,3 +94,38 @@ func TestSubList(t *testing.T) { }) } } + +func TestFirstOrZero(t *testing.T) { + testCases := []struct { + name string + slice []int + first int + }{ + { + name: "multiple items slice", + slice: []int{1, 2, 3}, + first: 1, + }, + { + name: "single item slice", + slice: []int{1}, + first: 1, + }, + { + name: "empty slice", + slice: []int{}, + first: 0, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + + first := FirstOrZero(tc.slice) + + if first != tc.first { + t.Errorf("Error first, want %d got %d", tc.first, first) + } + + }) + } +} -- cgit v1.2.3