Open tupsut opened 5 years ago
This is a userland behavior, as the library is only responsible for line-by-line parsing (sa. Event::from_str
). In this case, the problem is the test case itself (let entries = lines.filter_map(|line| Event::from_str(line, 2019).ok());
).
The library itself currently accepts the inputs line-by-line, and the user needs to track changes in the context. However, in case a CLI is implemented, that would need to handle the context change.
I agree that the test case is unclear, and I may fix the test-case to take context into account.
Both current test documents (alpha_self and buffer) follow a system in which years "roll over" within the same document - that is, the document follows several years, years are split at certain headings, and all events are in chronologically ascending order. However, currently, there is no implementation for reading these headings or otherwise realising when a year has rolled over.
To replicate: Run cargo test -- --nocapture on mod.rs. Check the output - any events which are in a "rolled over" year still get assigned to the first (current/pre-defined) year.
Possible fixes:
A combination of the two behaviours might be convenient, though 1 is certainly easier and more reliable.