feat(quando-r1o): consolidate benchmarks and achieve 99.5% test coverage
Reorganized test suite with consolidated benchmarks and comprehensive edge case coverage, exceeding 95% minimum coverage requirement. Changes: - Created benchmark_test.go with all 52 benchmarks organized by category (arithmetic, clock, date, diff, format, inspection, parse, snap, unit) - Removed benchmarks from 9 individual test files for better organization - Added 6 edge case tests to improve coverage: * Format() unknown type fallback * formatLong() empty lang default * Format.String() unknown value * isYearPrefix() edge cases * StartOf()/EndOf() unsupported units - Added 3 DST transition tests: * Spring forward (23-hour day) * Fall back (25-hour day) * Multiple timezone preservation Results: - Test coverage: 97.7% → 99.5% (exceeds 95% target) - All 52 benchmarks consolidated and verified - All benchmarks meet performance targets - No test regressions Files modified: - Created: benchmark_test.go (580 lines) - Modified: 9 test files (removed benchmarks, added tests)
This commit is contained in:
parent
414dfbdbef
commit
889e78da90
11 changed files with 710 additions and 460 deletions
104
snap_test.go
104
snap_test.go
|
|
@ -465,77 +465,6 @@ func TestSnapTimezones(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// BenchmarkStartOfWeek benchmarks StartOf(Weeks)
|
||||
func BenchmarkStartOfWeek(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.StartOf(Weeks)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkEndOfWeek benchmarks EndOf(Weeks)
|
||||
func BenchmarkEndOfWeek(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.EndOf(Weeks)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkStartOfMonth benchmarks StartOf(Months)
|
||||
func BenchmarkStartOfMonth(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.StartOf(Months)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkEndOfMonth benchmarks EndOf(Months)
|
||||
func BenchmarkEndOfMonth(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.EndOf(Months)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkStartOfQuarter benchmarks StartOf(Quarters)
|
||||
func BenchmarkStartOfQuarter(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.StartOf(Quarters)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkEndOfQuarter benchmarks EndOf(Quarters)
|
||||
func BenchmarkEndOfQuarter(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.EndOf(Quarters)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkStartOfYear benchmarks StartOf(Years)
|
||||
func BenchmarkStartOfYear(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.StartOf(Years)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkEndOfYear benchmarks EndOf(Years)
|
||||
func BenchmarkEndOfYear(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.EndOf(Years)
|
||||
}
|
||||
}
|
||||
|
||||
// TestNext tests the Next() method for all weekdays
|
||||
func TestNext(t *testing.T) {
|
||||
|
|
@ -798,20 +727,29 @@ func TestNextPrevTimezones(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// BenchmarkNext benchmarks the Next() method
|
||||
func BenchmarkNext(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.Next(time.Friday)
|
||||
// TestStartOf_UnsupportedUnit tests StartOf() with unsupported unit
|
||||
func TestStartOf_UnsupportedUnit(t *testing.T) {
|
||||
date := From(time.Date(2026, 2, 15, 14, 30, 45, 0, time.UTC))
|
||||
|
||||
// Seconds is not supported by StartOf
|
||||
result := date.StartOf(Seconds)
|
||||
|
||||
// Should return unchanged date
|
||||
if !result.Time().Equal(date.Time()) {
|
||||
t.Errorf("StartOf(Seconds) should return unchanged date")
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkPrev benchmarks the Prev() method
|
||||
func BenchmarkPrev(b *testing.B) {
|
||||
date := Now()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = date.Prev(time.Friday)
|
||||
// TestEndOf_UnsupportedUnit tests EndOf() with unsupported unit
|
||||
func TestEndOf_UnsupportedUnit(t *testing.T) {
|
||||
date := From(time.Date(2026, 2, 15, 14, 30, 45, 0, time.UTC))
|
||||
|
||||
// Seconds is not supported by EndOf
|
||||
result := date.EndOf(Seconds)
|
||||
|
||||
// Should return unchanged date
|
||||
if !result.Time().Equal(date.Time()) {
|
||||
t.Errorf("EndOf(Seconds) should return unchanged date")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue