Skip to content

Commit d8393c4

Browse files
authored
[cxx-interop] [NFC] Adding tests for conversion from NSString to Swift string to std::string (swiftlang#84266)
Seems like [PR-83701](swiftlang#83701) already resolved rdar://151188240. I am adding more test cases for verification. Ref: [Issue-69870](swiftlang#69870)
1 parent 8e802be commit d8393c4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/Interop/SwiftToCxx/stdlib/string/string-to-nsstring.mm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,27 @@ int main() {
7676
assert(std::string(swiftStr) == "👨‍💻👩‍💻åäö");
7777
}
7878

79+
{
80+
NSString* arabic_ns = @"طاب يومك";
81+
auto swift_arabic = String::init(arabic_ns);
82+
auto std_arabic = (std::string)swift_arabic;
83+
assert(std_arabic == "طاب يومك");
84+
85+
NSString* mixed_ns = @"Hello مرحبا World";
86+
auto swift_mixed = String::init(mixed_ns);
87+
auto std_mixed = (std::string)swift_mixed;
88+
assert(std_mixed == "Hello مرحبا World");
89+
90+
NSString* hebrew_ns = @"שלום עולם";
91+
auto swift_hebrew = String::init(hebrew_ns);
92+
auto std_hebrew = (std::string)swift_hebrew;
93+
assert(std_hebrew == "שלום עולם");
94+
95+
NSString* chinese_ns = @"你好世界";
96+
auto swift_chinese = String::init(chinese_ns);
97+
auto std_chinese = (std::string)swift_chinese;
98+
assert(std_chinese == "你好世界");
99+
}
100+
79101
return 0;
80102
}

0 commit comments

Comments
 (0)