mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
- Add Tap: for side effects/debugging in pipelines - Add Transpose: flip matrix rows and columns - Add Unzip: split tuple slice into two slices - Add ParallelReduce: parallel reduction (experimental) - Add Replicate: create n copies of a value Comprehensive tests included for all functions. Resolves Issues 21, 22, 23, 24, 25 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
582 B
Go
29 lines
582 B
Go
package underscore_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
u "github.com/rjNemo/underscore"
|
|
)
|
|
|
|
func TestReplicate(t *testing.T) {
|
|
result := u.Replicate(3, "hello")
|
|
assert.Equal(t, []string{"hello", "hello", "hello"}, result)
|
|
}
|
|
|
|
func TestReplicateZero(t *testing.T) {
|
|
result := u.Replicate(0, 42)
|
|
assert.Equal(t, []int{}, result)
|
|
}
|
|
|
|
func TestReplicateNegative(t *testing.T) {
|
|
result := u.Replicate(-5, 42)
|
|
assert.Equal(t, []int{}, result)
|
|
}
|
|
|
|
func TestReplicateOne(t *testing.T) {
|
|
result := u.Replicate(1, 100)
|
|
assert.Equal(t, []int{100}, result)
|
|
}
|