@@ -3836,6 +3836,53 @@ class TestData : TestDataSuper {
3836
3836
}
3837
3837
}
3838
3838
}
3839
+
3840
+ func test_increaseCount( ) {
3841
+ guard #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) else { return }
3842
+ let initials : [ Range < UInt8 > ] = [
3843
+ 0 ..< 0 ,
3844
+ 0 ..< 2 ,
3845
+ 0 ..< 4 ,
3846
+ 0 ..< 8 ,
3847
+ 0 ..< 16 ,
3848
+ 0 ..< 32 ,
3849
+ 0 ..< 64
3850
+ ]
3851
+ let diffs = [ 0 , 1 , 2 , 4 , 8 , 16 , 32 ]
3852
+ for initial in initials {
3853
+ for diff in diffs {
3854
+ var data = Data ( initial)
3855
+ data. count += diff
3856
+ expectEqualSequence (
3857
+ Array ( initial) + Array( repeating: 0 , count: diff) ,
3858
+ data)
3859
+ }
3860
+ }
3861
+ }
3862
+
3863
+ func test_decreaseCount( ) {
3864
+ guard #available( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * ) else { return }
3865
+ let initials : [ Range < UInt8 > ] = [
3866
+ 0 ..< 0 ,
3867
+ 0 ..< 2 ,
3868
+ 0 ..< 4 ,
3869
+ 0 ..< 8 ,
3870
+ 0 ..< 16 ,
3871
+ 0 ..< 32 ,
3872
+ 0 ..< 64
3873
+ ]
3874
+ let diffs = [ 0 , 1 , 2 , 4 , 8 , 16 , 32 ]
3875
+ for initial in initials {
3876
+ for diff in diffs {
3877
+ guard initial. count >= diff else { continue }
3878
+ var data = Data ( initial)
3879
+ data. count -= diff
3880
+ expectEqualSequence (
3881
+ initial. dropLast ( diff) ,
3882
+ data)
3883
+ }
3884
+ }
3885
+ }
3839
3886
}
3840
3887
3841
3888
#if !FOUNDATION_XCTEST
@@ -4159,6 +4206,9 @@ if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
4159
4206
DataTests . test ( " test_nsdataSequence " ) { TestData ( ) . test_nsdataSequence ( ) }
4160
4207
DataTests . test ( " test_dispatchSequence " ) { TestData ( ) . test_dispatchSequence ( ) }
4161
4208
}
4209
+ DataTests . test ( " test_increaseCount " ) { TestData ( ) . test_increaseCount ( ) }
4210
+ DataTests . test ( " test_decreaseCount " ) { TestData ( ) . test_decreaseCount ( ) }
4211
+
4162
4212
4163
4213
// XCTest does not have a crash detection, whereas lit does
4164
4214
DataTests . test ( " bounding failure subdata " ) {
0 commit comments