File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Tests/FoundationEssentialsTests Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,14 @@ extension Data {
46
46
}
47
47
}
48
48
49
+ func createSomeData( _ length: Int ) -> Data {
50
+ var d = Data ( repeating: 42 , count: length)
51
+ // Set a byte to be another value just so we know we have a unique pointer to the backing
52
+ // For maximum inefficiency in the not equal case, set the last byte
53
+ d [ length - 1 ] = UInt8 . random ( in: UInt8 . min..< UInt8 . max)
54
+ return d
55
+ }
56
+
49
57
@Suite ( " Data " )
50
58
private final class DataTests {
51
59
@@ -197,6 +205,16 @@ private final class DataTests {
197
205
#expect( d1 == d2, " Data should be equal " )
198
206
}
199
207
208
+ @Test func identical( ) {
209
+ let d1 = createSomeData ( 1024 * 8 )
210
+ let d2 = createSomeData ( 1024 * 8 )
211
+
212
+ #expect( d1. isIdentical ( to: d1) , " Data should be identical " )
213
+ #expect( d2. isIdentical ( to: d2) , " Data should be identical " )
214
+ #expect( !( d1. isIdentical ( to: d2) ) , " Data should be identical " )
215
+ #expect( !( d2. isIdentical ( to: d1) ) , " Data should be identical " )
216
+ }
217
+
200
218
@Test func dataInSet( ) {
201
219
let d1 = dataFrom ( " Hello " )
202
220
let d2 = dataFrom ( " Hello " )
You can’t perform that action at this time.
0 commit comments