File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
test/Interop/Cxx/stdlib/overlay Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ extension std.string: ExpressibleByStringLiteral {
25
25
}
26
26
}
27
27
28
+ extension std . string : CustomDebugStringConvertible {
29
+ public var debugDescription : String {
30
+ return " std.string( \( String ( cxxString: self ) ) ) "
31
+ }
32
+ }
33
+
28
34
extension String {
29
35
public init ( cxxString: std . string ) {
30
36
let buffer = UnsafeBufferPointer < CChar > (
Original file line number Diff line number Diff line change @@ -37,6 +37,21 @@ StdStringOverlayTestSuite.test("std::string <=> Swift.String") {
37
37
expectEqual ( swift6, " xyz \0 abc " )
38
38
}
39
39
40
+ StdStringOverlayTestSuite . test ( " std::string as Swift.CustomDebugStringConvertible " ) {
41
+ let cxx1 = std. string ( )
42
+ expectEqual ( cxx1. debugDescription, " std.string() " )
43
+
44
+ let cxx2 = std. string ( " something123 " )
45
+ expectEqual ( cxx2. debugDescription, " std.string(something123) " )
46
+
47
+ let bytes : [ UInt8 ] = [ 0xE1 , 0xC1 , 0xAC ]
48
+ var cxx3 = std. string ( )
49
+ for byte in bytes {
50
+ cxx3. push_back ( CChar ( bitPattern: byte) )
51
+ }
52
+ expectEqual ( cxx3. debugDescription, " std.string(���) " )
53
+ }
54
+
40
55
StdStringOverlayTestSuite . test ( " std::string as Swift.Sequence " ) {
41
56
let cxx1 = std. string ( )
42
57
var iterated = false
You can’t perform that action at this time.
0 commit comments