1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 00:02:28 +08:00

refactor(slice): optimize function (#211)

This commit is contained in:
Cannian
2024-04-06 09:16:28 +08:00
committed by GitHub
parent e461acdb72
commit 6853d627f4
2 changed files with 46 additions and 13 deletions

View File

@@ -2,12 +2,11 @@ package slice
import (
"fmt"
"github.com/duke-git/lancet/v2/internal"
"math"
"reflect"
"strconv"
"testing"
"github.com/duke-git/lancet/v2/internal"
)
func TestContain(t *testing.T) {
@@ -109,6 +108,19 @@ func TestConcat(t *testing.T) {
assert.Equal([]int{1, 2, 3, 4, 5}, Concat([]int{1, 2, 3}, []int{4}, []int{5}))
}
func BenchmarkConcat(b *testing.B) {
slice1 := []int{1, 2, 3}
slice2 := []int{4, 5, 6}
slice3 := []int{7, 8, 9}
for i := 0; i < b.N; i++ {
result := Concat(slice1, slice2, slice3)
if len(result) == 0 {
b.Fatal("unexpected empty result")
}
}
}
func TestEqual(t *testing.T) {
t.Parallel()