Skip to content

fix: return empty string from capitalize on empty input (#337) - #343

Merged
pantor merged 3 commits into
pantor:mainfrom
sofiamartincraft:fix/capitalize-empty-337
Aug 18, 2026
Merged

pantor merged 3 commits into
pantor:mainfrom
sofiamartincraft:fix/capitalize-empty-337

Conversation

@sofiamartincraft

Copy link
Copy Markdown
Contributor

Summary

Makes capitalize("") return an empty string instead of indexing past the end (#337).

Change

Guard the first-character toupper / remaining tolower transform behind !result.empty().

Test

Adds an empty-string case to the capitalize subcase in test/test-functions.cpp.

Closes #337

Signed-off-by: sofiamartincraft <sofiamartincraft@users.noreply.github.com>
Signed-off-by: sofiamartincraft <sofiamartincraft@users.noreply.github.com>
Signed-off-by: sofiamartincraft <sofiamartincraft@users.noreply.github.com>
@pantor
pantor merged commit fb1437b into pantor:main Aug 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

capitalize("") causes a crash

2 participants