Fix failing QueryParser Flexible tests due to zh-Hant-TW culture bug, #846 #1078
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes tests that fail randomly when the randomly selected culture is zh-Hant-TW and the time zone offset is negative.
Partial #846
Description
See this comment for full details explaining the problem: #846 (comment)
The solution was to ensure that the zh-Hant-TW culture (on .NET 6-8 when it is missing the
tt
in the LongTimePattern) does not pass the "sanity" check when there is a time zone with a negative offset due to this round-trip formatting/parsing bug. There already was a sanity check for the unix epoch (long value 0) which ensured the round-trip to/from string was parsed successfully, but it was not checking that it was parsed correctly. This code had been modified heavily from the original Lucene and was missing this equality check.While investigating this, there were opportunities to clean up the code in this class, as well as to make it support using the
[Repeat]
attribute to help in diagnosing issues. The use ofString
was normalized to thestring
keyword, some redundant parentheses were removed, and the method capitalization was fixed. To enable[Repeat]
support, several fields were moved from static to instance fields, andOneTimeSetUp
/OneTimeTearDown
was replaced withSetUp
/TearDown
. This allows for generating new random values when you repeat the test. Additionally, some extra info was added to the test assertion message to aid diagnosing issues if it fails.