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
64
diff_test.go
64
diff_test.go
|
|
@ -495,49 +495,6 @@ func TestDurationCrossBoundaries(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// BenchmarkDurationSeconds benchmarks Seconds()
|
||||
func BenchmarkDurationSeconds(b *testing.B) {
|
||||
start := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)
|
||||
dur := Diff(start, end)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = dur.Seconds()
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkDurationDays benchmarks Days()
|
||||
func BenchmarkDurationDays(b *testing.B) {
|
||||
start := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)
|
||||
dur := Diff(start, end)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = dur.Days()
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkDurationMonths benchmarks Months()
|
||||
func BenchmarkDurationMonths(b *testing.B) {
|
||||
start := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)
|
||||
dur := Diff(start, end)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = dur.Months()
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkDurationMonthsFloat benchmarks MonthsFloat()
|
||||
func BenchmarkDurationMonthsFloat(b *testing.B) {
|
||||
start := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)
|
||||
dur := Diff(start, end)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = dur.MonthsFloat()
|
||||
}
|
||||
}
|
||||
|
||||
// TestFloatPrecision verifies that float methods provide better precision
|
||||
func TestFloatPrecision(t *testing.T) {
|
||||
|
|
@ -735,24 +692,3 @@ func TestDurationHumanAdaptiveGranularity(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func BenchmarkDurationHuman(b *testing.B) {
|
||||
start := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := time.Date(2026, 11, 17, 5, 30, 45, 0, time.UTC)
|
||||
dur := Diff(start, end)
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = dur.Human(EN)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDurationHumanGerman(b *testing.B) {
|
||||
start := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
end := time.Date(2026, 11, 17, 5, 30, 45, 0, time.UTC)
|
||||
dur := Diff(start, end)
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = dur.Human(DE)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue