@@ -1637,6 +1637,7 @@ class DataTests : XCTestCase {
1637
1637
func test_InlineDataSpan( ) throws {
1638
1638
guard #available( FoundationSpan 6 . 2 , * ) else { throw XCTSkip ( " Span not available " ) }
1639
1639
1640
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1640
1641
var source = Data ( )
1641
1642
var span = source. span
1642
1643
XCTAssertTrue ( span. isEmpty)
@@ -1646,15 +1647,18 @@ class DataTests : XCTestCase {
1646
1647
XCTAssertFalse ( span. isEmpty)
1647
1648
XCTAssertEqual ( span. count, source. count)
1648
1649
XCTAssertEqual ( span [ 0 ] , 1 )
1650
+ #endif
1649
1651
}
1650
1652
1651
1653
func test_InlineSliceDataSpan( ) throws {
1652
1654
guard #available( FoundationSpan 6 . 2 , * ) else { throw XCTSkip ( " Span not available " ) }
1653
1655
1656
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1654
1657
let source = Data ( 0 ... . max)
1655
1658
let span = source. span
1656
1659
XCTAssertEqual ( span. count, source. count)
1657
1660
XCTAssertEqual ( span [ span. indices. last!] , . max)
1661
+ #endif
1658
1662
}
1659
1663
1660
1664
func test_LargeSliceDataSpan( ) throws {
@@ -1668,15 +1672,18 @@ class DataTests : XCTestCase {
1668
1672
#error("This test needs updating")
1669
1673
#endif
1670
1674
1675
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1671
1676
let source = Data ( repeating: 0 , count: count) . dropFirst ( )
1672
1677
XCTAssertNotEqual ( source. startIndex, 0 )
1673
1678
let span = source. span
1674
1679
XCTAssertFalse ( span. isEmpty)
1680
+ #endif
1675
1681
}
1676
1682
1677
1683
func test_InlineDataMutableSpan( ) throws {
1678
1684
guard #available( FoundationSpan 6 . 2 , * ) else { throw XCTSkip ( " Span not available " ) }
1679
1685
1686
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1680
1687
var source = Data ( )
1681
1688
var span = source. mutableSpan
1682
1689
XCTAssertTrue ( span. isEmpty)
@@ -1690,18 +1697,21 @@ class DataTests : XCTestCase {
1690
1697
let v = UInt8 . random ( in: 10 ..< 100 )
1691
1698
span [ i] = v
1692
1699
XCTAssertEqual ( source [ i] , v)
1700
+ #endif
1693
1701
}
1694
1702
1695
1703
func test_InlineSliceDataMutableSpan( ) throws {
1696
1704
guard #available( FoundationSpan 6 . 2 , * ) else { throw XCTSkip ( " Span not available " ) }
1697
1705
1706
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1698
1707
var source = Data ( 0 ..< 100 )
1699
1708
let count = source. count
1700
1709
var span = source. mutableSpan
1701
1710
XCTAssertEqual ( span. count, count)
1702
1711
let i = try XCTUnwrap ( span. indices. randomElement ( ) )
1703
1712
span [ i] = . max
1704
1713
XCTAssertEqual ( source [ i] , . max)
1714
+ #endif
1705
1715
}
1706
1716
1707
1717
func test_LargeSliceDataMutableSpan( ) throws {
@@ -1715,6 +1725,7 @@ class DataTests : XCTestCase {
1715
1725
#error("This test needs updating")
1716
1726
#endif
1717
1727
1728
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1718
1729
var source = Data ( repeating: 0 , count: count) . dropFirst ( )
1719
1730
XCTAssertNotEqual ( source. startIndex, 0 )
1720
1731
count = source. count
@@ -1724,11 +1735,13 @@ class DataTests : XCTestCase {
1724
1735
span [ i] = . max
1725
1736
XCTAssertEqual ( source [ i] , 0 )
1726
1737
XCTAssertEqual ( source [ i+ 1 ] , . max)
1738
+ #endif
1727
1739
}
1728
1740
1729
1741
func test_InlineDataMutableRawSpan( ) throws {
1730
1742
guard #available( FoundationSpan 6 . 2 , * ) else { throw XCTSkip ( " Span not available " ) }
1731
1743
1744
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1732
1745
var source = Data ( )
1733
1746
var span = source. mutableBytes
1734
1747
XCTAssertTrue ( span. isEmpty)
@@ -1742,18 +1755,21 @@ class DataTests : XCTestCase {
1742
1755
let v = UInt8 . random ( in: 10 ..< 100 )
1743
1756
span. storeBytes ( of: v, toByteOffset: i, as: UInt8 . self)
1744
1757
XCTAssertEqual ( source [ i] , v)
1758
+ #endif
1745
1759
}
1746
1760
1747
1761
func test_InlineSliceDataMutableRawSpan( ) throws {
1748
1762
guard #available( FoundationSpan 6 . 2 , * ) else { throw XCTSkip ( " Span not available " ) }
1749
1763
1764
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1750
1765
var source = Data ( 0 ..< 100 )
1751
1766
let count = source. count
1752
1767
var span = source. mutableBytes
1753
1768
XCTAssertEqual ( span. byteCount, count)
1754
1769
let i = try XCTUnwrap ( span. byteOffsets. randomElement ( ) )
1755
1770
span. storeBytes ( of: - 1 , toByteOffset: i, as: Int8 . self)
1756
1771
XCTAssertEqual ( source [ i] , . max)
1772
+ #endif
1757
1773
}
1758
1774
1759
1775
func test_LargeSliceDataMutableRawSpan( ) throws {
@@ -1767,6 +1783,7 @@ class DataTests : XCTestCase {
1767
1783
#error("This test needs updating")
1768
1784
#endif
1769
1785
1786
+ #if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
1770
1787
var source = Data ( repeating: 0 , count: count) . dropFirst ( )
1771
1788
XCTAssertNotEqual ( source. startIndex, 0 )
1772
1789
count = source. count
@@ -1776,6 +1793,7 @@ class DataTests : XCTestCase {
1776
1793
span. storeBytes ( of: - 1 , toByteOffset: i, as: Int8 . self)
1777
1794
XCTAssertEqual ( source [ i] , 0 )
1778
1795
XCTAssertEqual ( source [ i+ 1 ] , . max)
1796
+ #endif
1779
1797
}
1780
1798
1781
1799
#if false // FIXME: XCTest doesn't support crash tests yet rdar://20195010&22387653
0 commit comments