File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -241,11 +241,7 @@ extension String {
241
241
@inlinable
242
242
public var utf8 : UTF8View {
243
243
@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) }
249
245
}
250
246
251
247
/// A contiguously stored null-terminated UTF-8 representation of the string.
Original file line number Diff line number Diff line change @@ -796,4 +796,28 @@ tests.test("String.UTF32View/BidirectionalCollection")
796
796
test. unicodeScalars, test. string. unicodeScalars) { $0 == $1 }
797
797
}
798
798
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
+
799
823
runAllTests ( )
You can’t perform that action at this time.
0 commit comments