Skip to content

Preserve empty and single-character fields when splitting strings - #3234

Merged
horenmar merged 2 commits into
catchorg:develfrom
astunm:fix/single-character-enum-names
Nov 15, 2026
Merged

horenmar merged 2 commits into
catchorg:develfrom
astunm:fix/single-character-enum-names

Conversation

@astunm

@astunm astunm commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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-tests preset pass locally, including reporter approvals and regenerated amalgamated tests. The focused string and enum tests pass all 67 assertions.

GitHub Issues

No existing issue.

CHECK_THAT( splitStringRef( "a,b,c", ',' ),
Equals( std::vector<StringRef>{ "a", "b", "c" } ) );
CHECK_THAT( splitStringRef( "a,", ',' ),
Equals( std::vector<StringRef>{ "a" } ) );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return

Suggested change
Equals( std::vector<StringRef>{ "a" } ) );
Equals( std::vector<StringRef>{ "a", "" } ) );

CHECK_THAT( splitStringRef( "a,", ',' ),
Equals( std::vector<StringRef>{ "a" } ) );
CHECK_THAT( splitStringRef( ",a,,b,", ',' ),
Equals( std::vector<StringRef>{ "a", "b" } ) );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this should be checked against

Suggested change
Equals( std::vector<StringRef>{ "a", "b" } ) );
Equals( std::vector<StringRef>{ "", "a", "", "b", "" } ) );

@horenmar horenmar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@astunm astunm changed the title Preserve single-character fields when splitting strings Preserve empty and single-character fields when splitting strings Nov 13, 2026
@astunm

astunm commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@horenmar Updated in 11f4eb8: empty fields are preserved, including consecutive and trailing delimiters. Corrected both expectations and added "a,,,b" plus a delimiter-only case. All 156 all-tests checks pass locally.

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.38%. Comparing base (a1a991f) to head (11f4eb8).
⚠️ Report is 2 commits behind head on devel.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@horenmar horenmar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@horenmar
horenmar merged commit 36c1bc3 into catchorg:devel Nov 15, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants