-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] properly promote stack buffer to heap buffer when necessary #20585
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2183,4 +2183,19 @@ for test in comparisonTestCases { | |
} | ||
} | ||
|
||
StringTests.test("NormalizationBufferCrashRegressionTest") { | ||
let str = "\u{0336}\u{0344}\u{0357}\u{0343}\u{0314}\u{0351}\u{0340}\u{0300}\u{0340}\u{0360}\u{0314}\u{0357}\u{0315}\u{0301}\u{0344}a" | ||
let set = Set([str]) | ||
|
||
expectTrue(set.contains(str)) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any expectation on what this should normalize to? Can we write a test for that? |
||
StringTests.test("NormalizationCheck") { | ||
let str = "\u{0336}\u{0344}\u{0357}\u{0343}\u{0314}\u{0351}\u{0340}\u{0300}\u{0340}\u{0360}\u{0314}\u{0357}\u{0315}\u{0301}\u{0344}a" | ||
let nfcCodeUnits = str._nfcCodeUnits | ||
let expectedCodeUnits: [UInt8] = [0xCC, 0xB6, 0xCC, 0x88, 0xCC, 0x81, 0xCD, 0x97, 0xCC, 0x93, 0xCC, 0x94, 0xCD, 0x91, 0xCC, 0x80, 0xCC, 0x80, 0xCC, 0x80, 0xCC, 0x94, 0xCD, 0x97, 0xCC, 0x81, 0xCC, 0x88, 0xCC, 0x81, 0xCC, 0x95, 0xCD, 0xA0, 0x61] | ||
|
||
expectEqual(expectedCodeUnits, nfcCodeUnits) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were you able to test the case where the previous approach would've skipped over the long segment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this new test caught it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The concern was that a corner case would cause us to skip a portion of the String. Unfortunately, a test case expressed in terms of string comparison is only testing behavioral consistency but not the actual result. We have |
||
runAllTests() |
Uh oh!
There was an error while loading. Please reload this page.