Skip to content

Revamp sf::String tests#3418

Merged
ChrisThrasher merged 2 commits into
masterfrom
test_string
Feb 5, 2025
Merged

Revamp sf::String tests#3418
ChrisThrasher merged 2 commits into
masterfrom
test_string

Conversation

@ChrisThrasher

@ChrisThrasher ChrisThrasher commented Feb 4, 2025

Copy link
Copy Markdown
Member

Description

Related to #3406

I wrote the sf::String tests (see #2466) with no knowledge of how Unicode works, therefore the tests did a poor job actually testing all the Unicode-aware features of the class. I rewrote most of the tests to use Unicode codepoints more often. These new tests will do a much better job catching regressions.

In this same PR I also included a separate commit that removes hex code from strings in favor of the actual Unicode characters those hex values correspond to. Nobody would know that \U0001F40D means the 🐌 emoji. I know that because \U0001F40D is actually 🐍! The snail is \U0001F40C. Aren't you glad you can just see the character with your own eyes without having to check the web while reading the tests? Adding these characters required adding the /utf-8 code to MSVC builds.

These tests mostly exercise happy path code. There are many more tests we could theoretically add with error cases and non-default std::locale values but I chose to hold off on those for now.

@ChrisThrasher

Copy link
Copy Markdown
Member Author

Attn: @FRex

Comment thread cmake/Macros.cmake
Comment thread test/System/String.test.cpp Outdated

@eXpl0it3r eXpl0it3r 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.

I feel like select is quite a non-speaking name. I had to scroll up and read the comment just to understand what the what's supposed to do.

@ChrisThrasher ChrisThrasher merged commit 4c632e5 into master Feb 5, 2025
@ChrisThrasher ChrisThrasher deleted the test_string branch February 5, 2025 21:04
@ChrisThrasher

Copy link
Copy Markdown
Member Author

I feel like select is quite a non-speaking name. I had to scroll up and read the comment just to understand what the what's supposed to do.

There's definitely room for improvement here. I'm open to suggestions. I can't think of a good name off the top of my head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants