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

fix(package): [slice] Fix RigthPadding and LeftPadding (#322)

* Fixes in  RightPadding and LeftPadding

* Tests cover padding empty, nil, and negative lenght

* Implemented repeat, concat, and grow functionalities as internal.
This commit is contained in:
Idichekop
2025-08-04 04:45:29 +02:00
committed by GitHub
parent cb8d93c499
commit 6f703fe577
3 changed files with 97 additions and 22 deletions

View File

@@ -1756,6 +1756,20 @@ func TestRightPaddingAndLeftPadding(t *testing.T) {
padded := LeftPadding(RightPadding(nums, 0, 3), 0, 3)
assert.Equal([]int{0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0}, padded)
// Test with negative padding length
paddedNegative := LeftPadding(RightPadding(nums, 0, -3), 0, -3)
assert.Equal([]int{1, 2, 3, 4, 5}, paddedNegative)
// Test with empty slice
empty := []int{}
paddedEmpty := LeftPadding(RightPadding(empty, 0, 3), 0, 3)
assert.Equal([]int{0, 0, 0, 0, 0, 0}, paddedEmpty)
// Test with nil
nilSlice := []int(nil)
paddedNil := LeftPadding(RightPadding(nilSlice, 0, 3), 0, 3)
assert.Equal([]int{0, 0, 0, 0, 0, 0}, paddedNil)
}
func TestUniqueByConcurrent(t *testing.T) {