-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed HSTRING projection to use WindowsPreallocateStringBuffer to s…
…ave an allocation and copy.
- Loading branch information
1 parent
c98f4ea
commit 4794f3c
Showing
6 changed files
with
64 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import XCTest | ||
import WindowsRuntime | ||
|
||
internal final class HStringTests: XCTestCase { | ||
func testEmptyString() throws { | ||
XCTAssertNil(try HStringProjection.toABI("")) | ||
XCTAssertEqual(HStringProjection.toSwift(nil), "") | ||
} | ||
|
||
func testRoundTrip() throws { | ||
func assertRoundTrip(_ str: String) throws{ | ||
var abi = try HStringProjection.toABI(str) | ||
let roundtripped = HStringProjection.toSwift(consuming: &abi) | ||
XCTAssertEqual(str, roundtripped) | ||
} | ||
|
||
try assertRoundTrip("") | ||
try assertRoundTrip("a") | ||
try assertRoundTrip("à") | ||
try assertRoundTrip("☃") | ||
} | ||
} |