underscore/transpose_test.go
Ruidy d6f1e1cff5
feat: add Tap, Transpose, Unzip, ParallelReduce, and Replicate
- 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>
2025-11-14 14:55:43 +01:00

28 lines
606 B
Go

package underscore_test
import (
"testing"
"github.com/stretchr/testify/assert"
u "github.com/rjNemo/underscore"
)
func TestTranspose(t *testing.T) {
matrix := [][]int{{1, 2, 3}, {4, 5, 6}}
result := u.Transpose(matrix)
expected := [][]int{{1, 4}, {2, 5}, {3, 6}}
assert.Equal(t, expected, result)
}
func TestTransposeEmpty(t *testing.T) {
result := u.Transpose([][]int{})
assert.Equal(t, [][]int{}, result)
}
func TestTransposeSquare(t *testing.T) {
matrix := [][]int{{1, 2}, {3, 4}}
result := u.Transpose(matrix)
expected := [][]int{{1, 3}, {2, 4}}
assert.Equal(t, expected, result)
}