-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test string edge cases for Kotlin and Swift (#1602)
* Test string edge cases for Kotlin and Swift * Kotlin: Throw `CharacterCodingException` on invalid UTF-16 `String` This exception is produced using `CharsetEncoder.onUnmappableCharacter(CodingErrorAction.REPORT)`.
- Loading branch information
1 parent
826ea99
commit d146cf6
Showing
5 changed files
with
49 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import uniffi.uniffi_type_limits.*; | ||
|
||
// test_strings | ||
try { | ||
takeString("\ud800") | ||
throw RuntimeException("Should have thrown an CharacterCodingException exception!") | ||
} catch (e: java.nio.charset.CharacterCodingException) { | ||
// It's okay! | ||
} | ||
assert(takeString("") == "") | ||
assert(takeString("愛") == "愛") | ||
assert(takeString("💖") == "💖") |
14 changes: 14 additions & 0 deletions
14
fixtures/type-limits/tests/bindings/test_type_limits.swift
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,14 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import Foundation | ||
import uniffi_type_limits | ||
|
||
// test_strings | ||
do { | ||
// strings cannot contain surrogates, "\u{d800}" gives an error. | ||
assert(takeString(v: "") == "") | ||
assert(takeString(v: "愛") == "愛") | ||
assert(takeString(v: "💖") == "💖") | ||
} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
uniffi::build_foreign_language_testcases!( | ||
"tests/bindings/test_type_limits.kts", | ||
"tests/bindings/test_type_limits.py", | ||
"tests/bindings/test_type_limits.rb", | ||
"tests/bindings/test_type_limits.swift", | ||
); |
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