@@ -201,6 +201,49 @@ class SectionInsertionTests: XCTestCase {
201201 XCTAssertEqual ( form. allRows [ 2 ] , bRow)
202202 }
203203
204+ func testDeletingRows( ) {
205+ let form = Form ( )
206+ let section = Section ( " section_01 " )
207+ form. append ( section)
208+
209+ section. append ( NameRow ( tag: " row_01 " ) )
210+ section. append ( NameRow ( tag: " row_2 " ) )
211+ section. append ( NameRow ( " row_03 " ) { $0. hidden = true } )
212+ section. append ( NameRow ( " row_04 " ) { $0. hidden = true } )
213+
214+ section. removeAll ( where: { row in row. tag? . hasPrefix ( " row_0 " ) ?? false } )
215+ XCTAssertNotNil ( form. rowBy ( tag: " row_2 " ) )
216+ XCTAssertEqual ( form. allRows. count, 1 )
217+ }
218+
219+ func testDeletingSections( ) {
220+ let form = Form ( )
221+ form +++ Section ( " section_0 " )
222+ +++ Section ( " section_1 " ) { $0. hidden = true }
223+ +++ Section ( " section_22 " )
224+ +++ Section ( " section_32 " )
225+
226+ form. removeAll ( where: { section in section. header? . title? . hasSuffix ( " 2 " ) ?? false } )
227+ XCTAssertEqual ( form. allSections. count, 2 )
228+ }
229+
230+ func testReplaceAllSection( ) {
231+ let form = Form ( ) +++ Section ( " section1 " ) {
232+ $0. hidden = true
233+ }
234+ +++ Section ( " section2 " )
235+ +++ Section ( " section3 " )
236+
237+ form. replaceSubrangeInAllSections ( Range < Int > ( uncheckedBounds: ( lower: 0 , upper: 2 ) ) , with: [ Section ( " section0 " ) { $0. hidden = true } ] )
238+
239+ XCTAssertEqual ( form. allSections. count, 2 )
240+ XCTAssertEqual ( form. count, 1 )
241+ XCTAssertEqual ( form [ 0 ] . header? . title, " section3 " )
242+ XCTAssertEqual ( form. allSections [ 0 ] . header? . title, " section0 " )
243+ XCTAssertEqual ( form. allSections [ 1 ] . header? . title, " section3 " )
244+ }
245+
246+
204247 private func hideAndShowSections( form: Form , expectedTitles titles: [ String ] ) {
205248 // Doesn't matter how rows were added to the form (using append, +++ or subscript index)
206249 // next must work
0 commit comments