mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
Adds extensive edge case tests for core functions to catch regressions and ensure robust behavior. Test coverage added: - Empty slice tests: Filter, Map, Partition, Reduce, Unique, Last - Single element tests: Filter, Map, Partition, Reduce, Unique, Last - Large dataset tests: Filter (10k), Map (10k) - Boundary cases: Partition (all pass/reject), Unique (no dups/all same) Functions tested: - Filter: 4 new tests (empty, single, single no match, large) - Partition: 4 new tests (empty, single, all pass, all reject) - Last: 2 new tests (empty panic, single element) - Map: 3 new tests (empty, single, large) - Unique: 4 new tests (empty, single, no dups, all same) - Reduce: 2 new tests (empty, single) Results: - All 118 tests pass - Coverage: 98.4% (maintained high coverage) - Verified panic behavior for edge cases 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
753 B
Go
38 lines
753 B
Go
package underscore_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
u "github.com/rjNemo/underscore"
|
|
)
|
|
|
|
func TestUnique(t *testing.T) {
|
|
nums := []int{1, 4, 2, 5, 3, 1, 5, 2, 8, 9}
|
|
want := []int{1, 4, 2, 5, 3, 8, 9}
|
|
|
|
assert.Equal(t, want, u.Unique(nums))
|
|
}
|
|
|
|
func TestUniqueEmpty(t *testing.T) {
|
|
result := u.Unique([]int{})
|
|
assert.Empty(t, result)
|
|
}
|
|
|
|
func TestUniqueSingleElement(t *testing.T) {
|
|
result := u.Unique([]int{42})
|
|
assert.Equal(t, []int{42}, result)
|
|
}
|
|
|
|
func TestUniqueNoDuplicates(t *testing.T) {
|
|
nums := []int{1, 2, 3, 4, 5}
|
|
result := u.Unique(nums)
|
|
assert.Equal(t, nums, result)
|
|
}
|
|
|
|
func TestUniqueAllSame(t *testing.T) {
|
|
nums := []int{5, 5, 5, 5, 5}
|
|
result := u.Unique(nums)
|
|
assert.Equal(t, []int{5}, result)
|
|
}
|