diff --git a/fs/writer_test.go b/fs/writer_test.go index 7a7a746..3f9c901 100644 --- a/fs/writer_test.go +++ b/fs/writer_test.go @@ -11,6 +11,8 @@ import ( ) func TestMkdirAllExists(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -29,6 +31,8 @@ func TestMkdirAllExists(t *testing.T) { } func TestMkdirAllMkdirFails(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -45,6 +49,8 @@ func TestMkdirAllMkdirFails(t *testing.T) { } func TestMkdirAllStatFails(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -60,6 +66,8 @@ func TestMkdirAllStatFails(t *testing.T) { } func TestMkdirAllParentIsFile(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -80,6 +88,8 @@ func TestMkdirAllParentIsFile(t *testing.T) { } func TestMkdirAllPartialExists(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -102,6 +112,8 @@ func TestMkdirAllPartialExists(t *testing.T) { } func TestMkdirAll(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -120,6 +132,8 @@ func TestMkdirAll(t *testing.T) { } func TestWriteFileFS(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -133,6 +147,8 @@ func TestWriteFileFS(t *testing.T) { } func TestWriteFile(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -150,6 +166,8 @@ func TestWriteFile(t *testing.T) { } func TestWriteFileCreateFails(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -163,6 +181,8 @@ func TestWriteFileCreateFails(t *testing.T) { } func TestWriteFileWriteFails(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -179,6 +199,8 @@ func TestWriteFileWriteFails(t *testing.T) { } func TestWriteFileChmodFails(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() diff --git a/generic/math_test.go b/generic/math_test.go index af522ae..0031335 100644 --- a/generic/math_test.go +++ b/generic/math_test.go @@ -9,6 +9,8 @@ import ( ) func TestCountDeltas(t *testing.T) { + t.Parallel() + d := generic.CountDeltas(1.0, 10.0, 1.0) assert.Equal(t, 9, d) diff --git a/generic/minmax_test.go b/generic/minmax_test.go index 7f5f28e..314e15b 100644 --- a/generic/minmax_test.go +++ b/generic/minmax_test.go @@ -9,6 +9,8 @@ import ( ) func TestCompare(t *testing.T) { + t.Parallel() + a := 42 b := 13 @@ -19,6 +21,8 @@ func TestCompare(t *testing.T) { } func TestLess(t *testing.T) { + t.Parallel() + a := 42 b := 13 @@ -27,6 +31,8 @@ func TestLess(t *testing.T) { } func TestMax(t *testing.T) { + t.Parallel() + a := 42 b := 13 @@ -35,6 +41,8 @@ func TestMax(t *testing.T) { } func TestMin(t *testing.T) { + t.Parallel() + a := 42 b := 13 @@ -49,6 +57,8 @@ func (a compare) Compare(b generic.ComparableInterface) generic.Comparison { } func TestLessI(t *testing.T) { + t.Parallel() + a := compare(42) b := compare(13) @@ -57,6 +67,8 @@ func TestLessI(t *testing.T) { } func TestMaxI(t *testing.T) { + t.Parallel() + a := compare(42) b := compare(13) @@ -65,6 +77,8 @@ func TestMaxI(t *testing.T) { } func TestMinI(t *testing.T) { + t.Parallel() + a := compare(42) b := compare(13) diff --git a/generic/value_test.go b/generic/value_test.go index c24d813..f199ca8 100644 --- a/generic/value_test.go +++ b/generic/value_test.go @@ -9,6 +9,8 @@ import ( ) func TestFirstNonZero(t *testing.T) { + t.Parallel() + assert.Equal(t, 1, generic.FirstNonZero[int](0, 1, 2)) assert.Equal(t, 1, generic.FirstNonZero[int](1, 0, 2)) assert.Equal(t, 1, generic.FirstNonZero[int](0, 0, 1)) @@ -16,6 +18,8 @@ func TestFirstNonZero(t *testing.T) { } func TestFirstNonNil(t *testing.T) { + t.Parallel() + var a *int b := new(int) c := new(int) @@ -29,6 +33,8 @@ func TestFirstNonNil(t *testing.T) { } func TestZero(t *testing.T) { + t.Parallel() + assert.Equal(t, 0, generic.Zero[int]()) assert.Equal(t, "", generic.Zero[string]()) assert.Equal(t, rune(0), generic.Zero[rune]()) diff --git a/maps/copy_test.go b/maps/copy_test.go index 162d6ac..3635c5d 100644 --- a/maps/copy_test.go +++ b/maps/copy_test.go @@ -9,6 +9,8 @@ import ( ) func TestCopyInit(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, @@ -22,6 +24,8 @@ func TestCopyInit(t *testing.T) { } func TestCopy(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, @@ -35,6 +39,8 @@ func TestCopy(t *testing.T) { } func TestCopy_SadNilDstPanics(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, @@ -48,6 +54,8 @@ func TestCopy_SadNilDstPanics(t *testing.T) { } func TestClear(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, diff --git a/maps/iterator_test.go b/maps/iterator_test.go index f93c671..29f7e3f 100644 --- a/maps/iterator_test.go +++ b/maps/iterator_test.go @@ -9,6 +9,8 @@ import ( ) func TestNewIterator(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, diff --git a/maps/merge_test.go b/maps/merge_test.go index 7a64496..ef00d06 100644 --- a/maps/merge_test.go +++ b/maps/merge_test.go @@ -9,6 +9,8 @@ import ( ) func TestMerge(t *testing.T) { + t.Parallel() + a := map[string]int{"a": 1, "b": 2} b := map[string]int{"c": 3, "d": 4} c := map[string]int{"a": 5, "b": 6, "c": 7} @@ -29,6 +31,8 @@ func TestMerge(t *testing.T) { } func TestMergeInPlace(t *testing.T) { + t.Parallel() + a := map[string]int{"a": 1, "b": 2} b := map[string]int{"c": 3, "d": 4} c := map[string]int{"a": 5, "b": 6, "c": 7} @@ -46,6 +50,8 @@ func TestMergeInPlace(t *testing.T) { } func TestDiff(t *testing.T) { + t.Parallel() + a := map[string]int{"one": 1, "two": 2, "three": 3, "four": 4} b := map[string]int{"one": 5, "three": 6, "five": 7, "seven": 8} diff --git a/maps/transform_test.go b/maps/transform_test.go index 97a42f9..d108401 100644 --- a/maps/transform_test.go +++ b/maps/transform_test.go @@ -9,6 +9,8 @@ import ( ) func TestKeys(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, @@ -23,6 +25,8 @@ func TestKeys(t *testing.T) { } func TestValues(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, @@ -37,6 +41,8 @@ func TestValues(t *testing.T) { } func TestKVs(t *testing.T) { + t.Parallel() + a := map[string]int{ "a": 1, "b": 2, diff --git a/set/set.go b/set/set.go index a9dbf10..48169ca 100644 --- a/set/set.go +++ b/set/set.go @@ -26,8 +26,8 @@ func New[T comparable](vals ...T) Set[T] { } // NewSized constructs a new set that is empty, but has the requested capacity. -func NewSized[T comparable](cap int) Set[T] { - return make(Set[T], cap) +func NewSized[T comparable](capacity int) Set[T] { + return make(Set[T], capacity) } // Contains returns true if the given value is contained within the set. diff --git a/set/set_test.go b/set/set_test.go index 588ed75..a688668 100644 --- a/set/set_test.go +++ b/set/set_test.go @@ -9,6 +9,8 @@ import ( ) func TestCopy(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New[int]() set.Copy(s2, s1) @@ -17,6 +19,8 @@ func TestCopy(t *testing.T) { } func TestCopyInit(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) var s2 set.Set[int] set.CopyInit(&s2, s1) @@ -25,6 +29,8 @@ func TestCopyInit(t *testing.T) { } func TestNew(t *testing.T) { + t.Parallel() + ss := []set.Set[int]{ set.New(1, 2, 3), set.New(3, 2, 1), @@ -42,6 +48,8 @@ func TestNew(t *testing.T) { } func TestSet_Contains(t *testing.T) { + t.Parallel() + s := set.New(1, 2, 3) assert.True(t, s.Contains(1)) @@ -51,6 +59,8 @@ func TestSet_Contains(t *testing.T) { } func TestSet_Delete(t *testing.T) { + t.Parallel() + s := set.New(1, 2, 3) s.Delete(0) @@ -70,6 +80,8 @@ func TestSet_Delete(t *testing.T) { } func TestSet_Insert(t *testing.T) { + t.Parallel() + s := set.New[int]() assert.Equal(t, set.New[int](), s) @@ -88,11 +100,15 @@ func TestSet_Insert(t *testing.T) { } func TestSet_Len(t *testing.T) { + t.Parallel() + s := set.New(1, 2, 3) assert.Equal(t, len(s), s.Len()) } func TestSet_SubsetOf(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New(2, 3) s3 := set.New(3, 4) @@ -109,6 +125,8 @@ func TestSet_SubsetOf(t *testing.T) { } func TestSet_Keys(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New(2, 3) s3 := set.New(3, 4) @@ -135,6 +153,8 @@ func TestSet_Keys(t *testing.T) { } func TestDifference(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New(3, 4, 5) @@ -144,6 +164,8 @@ func TestDifference(t *testing.T) { } func TestIntersection(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New(3, 4, 5, 6) @@ -153,6 +175,8 @@ func TestIntersection(t *testing.T) { } func TestIntersects(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New(3, 4, 5) s3 := set.New(5, 6, 7) @@ -169,6 +193,8 @@ func TestIntersects(t *testing.T) { } func TestUnion(t *testing.T) { + t.Parallel() + s1 := set.New(1, 2, 3) s2 := set.New(3, 4, 5, 6) @@ -177,6 +203,8 @@ func TestUnion(t *testing.T) { } func TestDiff(t *testing.T) { + t.Parallel() + a := set.New(1, 2, 3, 4) b := set.New(1, 3, 5, 7) diff --git a/slices/generate_test.go b/slices/generate_test.go index 3e6f624..9506df2 100644 --- a/slices/generate_test.go +++ b/slices/generate_test.go @@ -9,6 +9,8 @@ import ( ) func TestFromRange(t *testing.T) { + t.Parallel() + gotI := slices.FromRange(1, 10, 1) assert.Equal(t, []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, gotI) diff --git a/slices/iterator_test.go b/slices/iterator_test.go index 8630895..3ff3a7a 100644 --- a/slices/iterator_test.go +++ b/slices/iterator_test.go @@ -9,6 +9,8 @@ import ( ) func TestNewIterator(t *testing.T) { + t.Parallel() + a := []int{1, 2, 3} iter := slices.NewIterator(a) diff --git a/slices/manipulate_test.go b/slices/manipulate_test.go index 71d91fb..f1cb0b5 100644 --- a/slices/manipulate_test.go +++ b/slices/manipulate_test.go @@ -9,6 +9,8 @@ import ( ) func TestDelete(t *testing.T) { + t.Parallel() + var slice = []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} slice = slices.Delete(slice, 10) @@ -47,6 +49,8 @@ func TestDelete(t *testing.T) { } func TestDeleteValue(t *testing.T) { + t.Parallel() + s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 6} s = slices.DeleteValue(s, 0) @@ -75,6 +79,8 @@ func TestDeleteValue(t *testing.T) { } func TestDeleteAllValues(t *testing.T) { + t.Parallel() + s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 6} s = slices.DeleteAllValues(s, 0) @@ -103,6 +109,8 @@ func TestDeleteAllValues(t *testing.T) { } func TestInsert(t *testing.T) { + t.Parallel() + s := []int{1, 2, 3} s = slices.Insert(s, 0, 4) @@ -121,6 +129,8 @@ func TestInsert(t *testing.T) { } func TestPop(t *testing.T) { + t.Parallel() + s := []int{1, 2, 3} v, s := slices.Pop(s) @@ -141,7 +151,9 @@ func TestPop(t *testing.T) { } func TestPush(t *testing.T) { - s := []int{} + t.Parallel() + + var s []int s = slices.Push(s, 1) s = slices.Push(s, 2, 3) @@ -150,6 +162,8 @@ func TestPush(t *testing.T) { } func TestShift(t *testing.T) { + t.Parallel() + s := []int{1, 2, 3} v, s := slices.Shift(s) @@ -170,7 +184,9 @@ func TestShift(t *testing.T) { } func TestUnshift(t *testing.T) { - s := []int{} + t.Parallel() + + var s []int s = slices.Unshift(s, 1) s = slices.Unshift(s, 2, 3) @@ -179,9 +195,11 @@ func TestUnshift(t *testing.T) { } func TestConcat(t *testing.T) { + t.Parallel() + a := []int{1, 2, 3} b := []int{4, 5} - c := []int{} + var c []int d := []int{6, 7, 8} e := slices.Concat(a, b, c, d) diff --git a/slices/map_test.go b/slices/map_test.go index e6b86ed..228502e 100644 --- a/slices/map_test.go +++ b/slices/map_test.go @@ -38,6 +38,8 @@ func oddly(a int) int { } func TestMap(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} ss := slices.Map(in, toString) assert.Equal(t, []string{"1", "2", "3"}, ss) @@ -46,6 +48,8 @@ func TestMap(t *testing.T) { } func TestMapSlice(t *testing.T) { + t.Parallel() + halveTheOdds := func(i int) []float64 { if i%2 == 1 { return []float64{float64(i) / 2.0} @@ -62,6 +66,8 @@ func TestMapSlice(t *testing.T) { } func TestMapMap(t *testing.T) { + t.Parallel() + stringToInt := func(in int) map[string]int { return map[string]int{ strconv.Itoa(in): in, @@ -75,6 +81,8 @@ func TestMapMap(t *testing.T) { } func TestReduce(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} s := slices.Reduce(in, subtract) assert.Equal(t, -6, s) @@ -88,6 +96,8 @@ func TestReduce(t *testing.T) { } func TestReduceAcc(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} s := slices.ReduceAcc(in, 7, subtract) assert.Equal(t, 1, s) @@ -101,6 +111,8 @@ func TestReduceAcc(t *testing.T) { } func TestReductions(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} s := slices.Reductions(in, subtract) assert.Equal(t, []int{-1, -3, -6}, s) @@ -114,6 +126,8 @@ func TestReductions(t *testing.T) { } func TestReductionsAcc(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} s := slices.ReductionsAcc(in, 7, subtract) assert.Equal(t, []int{6, 4, 1}, s) @@ -127,6 +141,8 @@ func TestReductionsAcc(t *testing.T) { } func TestSum(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} s := slices.Sum(in) assert.Equal(t, 6, s) @@ -135,6 +151,8 @@ func TestSum(t *testing.T) { } func TestProduct(t *testing.T) { + t.Parallel() + in := []int{3, 4, 5} p := slices.Product(in) assert.Equal(t, 60, p) @@ -143,18 +161,24 @@ func TestProduct(t *testing.T) { } func TestGrep(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} assert.Equal(t, []int{1, 3}, slices.Grep(in, isOdd)) assert.Equal(t, []int{}, slices.Grep([]int{}, isOdd)) } func TestGrepIndex(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} assert.Equal(t, []int{0, 2}, slices.GrepIndex(in, isOdd)) assert.Equal(t, []int{}, slices.GrepIndex([]int{}, isOdd)) } func TestAny(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} assert.Equal(t, true, slices.Any(in, isOdd)) assert.Equal(t, false, slices.Any(slices.Map(in, double), isOdd)) @@ -162,6 +186,8 @@ func TestAny(t *testing.T) { } func TestAll(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} assert.Equal(t, false, slices.All(in, isOdd)) assert.Equal(t, true, slices.All(slices.Map(in, oddly), isOdd)) @@ -169,6 +195,8 @@ func TestAll(t *testing.T) { } func TestNone(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} assert.Equal(t, false, slices.None(in, isOdd)) assert.Equal(t, true, slices.None(slices.Map(in, double), isOdd)) @@ -176,6 +204,8 @@ func TestNone(t *testing.T) { } func TestNotAll(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} assert.Equal(t, true, slices.NotAll(in, isOdd)) assert.Equal(t, false, slices.NotAll(slices.Map(in, oddly), isOdd)) @@ -183,6 +213,8 @@ func TestNotAll(t *testing.T) { } func TestFirst(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} v, found := slices.First(in, isOdd) assert.Equal(t, 1, v) @@ -196,6 +228,8 @@ func TestFirst(t *testing.T) { } func TestFirstIndex(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} v := slices.FirstIndex(in, isOdd) assert.Equal(t, 0, v) @@ -206,6 +240,8 @@ func TestFirstIndex(t *testing.T) { } func TestFirstOr(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3} v := slices.FirstOr(in, -1, isOdd) assert.Equal(t, 1, v) diff --git a/slices/scheme_test.go b/slices/scheme_test.go index f8e6634..cdb44ef 100644 --- a/slices/scheme_test.go +++ b/slices/scheme_test.go @@ -9,6 +9,8 @@ import ( ) func TestHead(t *testing.T) { + t.Parallel() + assert.Equal(t, []int{1, 2, 3}, slices.Head([]int{1, 2, 3, 4, 5}, 3)) assert.Equal(t, []int{1, 2, 3}, slices.Head([]int{1, 2, 3}, 3)) assert.Equal(t, []int{1, 2}, slices.Head([]int{1, 2}, 3)) @@ -18,6 +20,8 @@ func TestHead(t *testing.T) { } func TestTail(t *testing.T) { + t.Parallel() + assert.Equal(t, []int{3, 4, 5}, slices.Tail([]int{1, 2, 3, 4, 5}, 3)) assert.Equal(t, []int{1, 2, 3}, slices.Tail([]int{1, 2, 3}, 3)) assert.Equal(t, []int{1, 2}, slices.Tail([]int{1, 2}, 3)) diff --git a/slices/sort_test.go b/slices/sort_test.go index ef6e3d6..ba02fb7 100644 --- a/slices/sort_test.go +++ b/slices/sort_test.go @@ -11,6 +11,8 @@ import ( ) func TestShuffle(t *testing.T) { + t.Parallel() + in := []int{1, 2, 3, 4, 5} slices.Shuffle(in) @@ -23,6 +25,8 @@ func TestShuffle(t *testing.T) { } func TestSample(t *testing.T) { + t.Parallel() + ins := [][]int{ {}, {1, 2}, @@ -49,6 +53,8 @@ func TestSample(t *testing.T) { } func TestUniq(t *testing.T) { + t.Parallel() + in := []int{1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 7} out := slices.Uniq(in) assert.Equal(t, []int{1, 2, 3, 4, 5, 6, 7}, out) @@ -56,6 +62,8 @@ func TestUniq(t *testing.T) { } func TestUniqInPlace(t *testing.T) { + t.Parallel() + in := []int{1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 7} in = slices.UniqInPlace(in) assert.Equal(t, []int{1, 2, 3, 4, 5, 6, 7}, in) diff --git a/strings/content_test.go b/strings/content_test.go index d00f913..a80ff98 100644 --- a/strings/content_test.go +++ b/strings/content_test.go @@ -9,6 +9,8 @@ import ( ) func TestContainsOnly(t *testing.T) { + t.Parallel() + assert.True(t, strings.ContainsOnly("abc", "abc")) assert.True(t, strings.ContainsOnly("a", "abc")) assert.True(t, strings.ContainsOnly("aaaaaabbbbbbccccc", "cba")) @@ -16,6 +18,8 @@ func TestContainsOnly(t *testing.T) { } func TestFromRange(t *testing.T) { + t.Parallel() + assert.Equal(t, "abcd", strings.FromRange('a', 'd')) assert.Equal(t, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", strings.FromRange('A', 'Z')) assert.Equal(t, "0123456789", strings.FromRange('0', '9')) @@ -23,10 +27,14 @@ func TestFromRange(t *testing.T) { } func TestReverse(t *testing.T) { + t.Parallel() + assert.Equal(t, ".txet gnisreveR", strings.Reverse("Reversing text.")) } func TestIncrement(t *testing.T) { + t.Parallel() + assert.Equal(t, "A", strings.Increment("")) assert.Equal(t, "B", strings.Increment("A")) assert.Equal(t, "AA", strings.Increment("Z")) diff --git a/structs/defaults_test.go b/structs/defaults_test.go index e363b13..97daca7 100644 --- a/structs/defaults_test.go +++ b/structs/defaults_test.go @@ -9,6 +9,8 @@ import ( ) func TestApplyDefaults(t *testing.T) { + t.Parallel() + type test struct { A string B int @@ -16,8 +18,8 @@ func TestApplyDefaults(t *testing.T) { } var ( - f = float64(13.0) - g = float64(14.0) + f = 13.0 + g = 14.0 one = test{ A: "foo", B: 42,