1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

String: Fix unit test failure for random seed 0xaccaaad0444426fa

This commit is contained in:
reuk 2024-10-07 14:11:37 +01:00
parent c57041e5bc
commit 77f3073d92
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -2373,7 +2373,8 @@ public:
{
String s (createRandomWideCharString (r));
typename CharPointerType::CharType buffer [300];
using CharType = typename CharPointerType::CharType;
CharType buffer[300];
memset (buffer, 0xff, sizeof (buffer));
CharPointerType (buffer).writeAll (s.toUTF32());
@ -2387,7 +2388,10 @@ public:
CharPointerType (buffer).writeAll (s.toUTF8());
test.expectEquals (String (CharPointerType (buffer)), s);
test.expect (CharPointerType::isValidString (buffer, (int) strlen ((const char*) buffer)));
const auto nullTerminator = std::find (buffer, buffer + std::size (buffer), (CharType) 0);
const auto numValidBytes = (int) std::distance (buffer, nullTerminator) * (int) sizeof (CharType);
test.expect (CharPointerType::isValidString (buffer, numValidBytes));
}
};