core: give a boundary hour to the next instance, real or inferred
TokenEnd only saw the real spans, so an instance kept the boundary hour that its inferred successor also counted. Two adjacent inferred weeks then both showed the same tokens, which made false past peaks (D7). One backward walk now yields every instance with the start of the instance that follows it. Analyze takes its first eight past instances from it and the reset history uses it for its real instances, so the window charts and the reset list agree. An instance that resets before a gap keeps its end hour, as before. Refs #14
This commit is contained in:
@@ -99,6 +99,17 @@ public sealed class LimitInstanceTests
|
||||
AssertNoOverlap(result);
|
||||
}
|
||||
|
||||
[Fact] public void AdjacentInferredWeeksAssignTheBoundaryHourOnlyToTheStartingWeek()
|
||||
{
|
||||
var start = Day.AddMinutes(13);
|
||||
var current = Window(start, TimeSpan.FromDays(7), start.AddHours(2), 20);
|
||||
var result = Analyze(current, [], [Token(Day, 100), Token(Day.AddDays(-7), 100)], current.SampleTime);
|
||||
var past = Assert.Single(result.Past);
|
||||
Assert.Equal(start.AddDays(-7), past.Start); Assert.Equal(20, past.Peak);
|
||||
Assert.DoesNotContain(result.Past, p => p.Start == start.AddDays(-14));
|
||||
AssertNoOverlap(result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(5)]
|
||||
[InlineData(24)]
|
||||
|
||||
Reference in New Issue
Block a user