-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for sf::String
#2466
Add tests for sf::String
#2466
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks a lot!
I think the tests may benefit from using some actual wide-char or UTF-32 characters where applicable, so we don't just have ASCII. See https://stackoverflow.com/q/6796157 for string literals 🙂
I wonder why there's no code coverage comment on this PR EDIT: It's working now |
4186590
to
c8d8d9f
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2466 +/- ##
==========================================
+ Coverage 22.72% 24.04% +1.32%
==========================================
Files 226 226
Lines 19388 19409 +21
Branches 4705 4714 +9
==========================================
+ Hits 4406 4667 +261
+ Misses 14469 14240 -229
+ Partials 513 502 -11
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Oh joy. It appears that many of the tests fail on Windows. Is this a bug in my tests or is this simply the reality of the implementation-defined behavior of wide strings? Is it a locale issue? If we're dealing with implementation-defined behavior then I'm not sure whether we can test most of these things to any meaningful degree. |
c8d8d9f
to
9be7741
Compare
8207a57
to
b030511
Compare
I think I found a satisfactory way to handle the fact that wide string encoding different on a per-platform basis. I'm using the width of a // Return either argument depending on whether wchar_t is 16 or 32 bits
// Lets us write tests that work on both Windows where wchar_t is 16 bits
// and elsewhere where it is 32. Otherwise the tests would only work on
// one OS or the other.
template <typename T>
T select(const T& t16, const T& t32)
{
assert(t16 != t32);
if constexpr (sizeof(wchar_t) == 2)
return t16;
else
return t32;
} A better function name probably exists but I kept it simple to begin with. |
I had to make |
fe10093
to
0e29e98
Compare
I think it's all good now |
0e29e98
to
5f513d4
Compare
3bdf737
to
47a8124
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor questions and I think we should "document" getSize
when clearing, erasing or adding.
47a8124
to
3eb478a
Compare
I believe I addressed all the comments |
This fails to link on MinGW. Until that can be resolved we can go back to a normal constant. Because this is just an integer it doesn't matter all that much whether it's const or constexpr.
Dates back to 2009 when 78247bd was written. I'm going to assume the situation has improved in the last 14 years. There are SFML users who weren't even alive in 2009...
3eb478a
to
e9963d3
Compare
I added more comments to clarify what's going on with these |
Description
These tests don't bother covering all edge or corner case behavior. Their intent is to test all the simple cases of
sf::String
and lay the groundwork for more sophisticated tests which may come later. I'm not experienced with wide strings or UTF-32 strings so I'm not even sure how to tackle testing the more complicated uses.