fix: 修复天象事件 API 在事件边界附近的重复返回问题
- 修正合月、合日、留等Last/Next/Closest接口在精确命中和事件后秒级查询时仍返回当前事件的问题,避免应用侧枚举卡死 - 收紧事件边界判定,并补强水星、金星、火星近事件路径的稳定化,保证公开API的单调前进语义 - 补充公开wrapper、跨世纪样本和外部基线回归,覆盖合月邻近事件与边界场景
This commit is contained in:
@@ -80,3 +80,24 @@ func TestInvalidConjunctionPlanetReturnsZeroTime(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNextConjunctionAdvancesPastReturnedEvent(t *testing.T) {
|
||||
cursor := time.Date(2026, 5, 1, 0, 0, 0, 0, time.UTC)
|
||||
first := NextConjunctionWithPlanet(cursor, ConjunctionMercury)
|
||||
query := first.Add(time.Second)
|
||||
next := NextConjunctionWithPlanet(query, ConjunctionMercury)
|
||||
|
||||
if !next.After(query) {
|
||||
t.Fatalf("expected next conjunction after query: query=%s next=%s delta=%v",
|
||||
query.Format(time.RFC3339Nano),
|
||||
next.Format(time.RFC3339Nano),
|
||||
next.Sub(query),
|
||||
)
|
||||
}
|
||||
if next.Equal(first) {
|
||||
t.Fatalf("expected next conjunction to advance: first=%s next=%s",
|
||||
first.Format(time.RFC3339Nano),
|
||||
next.Format(time.RFC3339Nano),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user