Skip to content

Commit 998d9c4

Browse files
authored
Merge pull request #22430 from milseman/whoops
2 parents 9f5bf22 + a742a62 commit 998d9c4

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

stdlib/public/core/StringUTF8View.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,7 @@ extension String {
241241
@inlinable
242242
public var utf8: UTF8View {
243243
@inline(__always) get { return UTF8View(self._guts) }
244-
set {
245-
// TODO(String testing): test suite doesn't currenlty exercise this code at
246-
// all, test it.
247-
self = String(utf8._guts)
248-
}
244+
set { self = String(newValue._guts) }
249245
}
250246

251247
/// A contiguously stored null-terminated UTF-8 representation of the string.

validation-test/stdlib/StringViews.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,4 +796,28 @@ tests.test("String.UTF32View/BidirectionalCollection")
796796
test.unicodeScalars, test.string.unicodeScalars) { $0 == $1 }
797797
}
798798

799+
tests.test("String View Setters") {
800+
var string = "abcd🤠👨‍👨‍👦‍👦efg"
801+
802+
string.utf8 = winter.utf8
803+
expectEqual(winter, string)
804+
string.utf8 = summer.utf8
805+
expectEqual(summer, string)
806+
807+
string.utf16 = winter.utf16
808+
expectEqual(winter, string)
809+
string.utf16 = summer.utf16
810+
expectEqual(summer, string)
811+
812+
string.unicodeScalars = winter.unicodeScalars
813+
expectEqual(winter, string)
814+
string.unicodeScalars = summer.unicodeScalars
815+
expectEqual(summer, string)
816+
817+
string = winter
818+
expectEqual(winter, string)
819+
string = summer
820+
expectEqual(summer, string)
821+
}
822+
799823
runAllTests()

0 commit comments

Comments
 (0)