Repository navigation
Preserve empty and single-character fields when splitting strings - #3234
Merged
Merged
Conversation
horenmar
reviewed
Nov 13, 2026
| CHECK_THAT( splitStringRef( "a,b,c", ',' ), | ||
| Equals( std::vector<StringRef>{ "a", "b", "c" } ) ); | ||
| CHECK_THAT( splitStringRef( "a,", ',' ), | ||
| Equals( std::vector<StringRef>{ "a" } ) ); |
Member
There was a problem hiding this comment.
This should return
Suggested change
| Equals( std::vector<StringRef>{ "a" } ) ); | |
| Equals( std::vector<StringRef>{ "a", "" } ) ); |
horenmar
reviewed
Nov 13, 2026
| CHECK_THAT( splitStringRef( "a,", ',' ), | ||
| Equals( std::vector<StringRef>{ "a" } ) ); | ||
| CHECK_THAT( splitStringRef( ",a,,b,", ',' ), | ||
| Equals( std::vector<StringRef>{ "a", "b" } ) ); |
Member
There was a problem hiding this comment.
Similarly, this should be checked against
Suggested change
| Equals( std::vector<StringRef>{ "a", "b" } ) ); | |
| Equals( std::vector<StringRef>{ "", "a", "", "b", "" } ) ); |
horenmar
requested changes
Nov 13, 2026
horenmar
left a comment
Member
There was a problem hiding this comment.
The old implementation of split is wrong, but this one isn't correct either. See notes on the added test cases, also please add splitStringRef("a,,,b", ',') as one test case.
Contributor
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #3234 +/- ##
==========================================
- Coverage 91.41% 91.38% -0.03%
==========================================
Files 205 205
Lines 9106 9105 -1
==========================================
- Hits 8324 8320 -4
- Misses 782 785 +3 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Preserve single-character and empty fields when splitting strings, including leading, consecutive and trailing delimiters. This also fixes registration of unqualified one-letter enum values. Empty input still returns no fields.
Tests: four corrected regression assertions fail on the previous PR version. All 156 checks in the full
all-testspreset pass locally, including reporter approvals and regenerated amalgamated tests. The focused string and enum tests pass all 67 assertions.GitHub Issues
No existing issue.