@@ -339,12 +339,13 @@ let trailer = [UInt8](repeating: 0, count: trailerSize)
339339 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
340340 ]
341341
342- @Test func testAppendingEmptyFile( ) async throws {
343- let archive = try Archive ( ) . appendingFile ( name: " emptyfile " , data: [ ] ) . bytes
342+ @Test func testAppendEmptyFile( ) async throws {
343+ let archive = Archive ( )
344+ try archive. appendFile ( name: " emptyfile " , data: [ ] )
344345
345346 // Expecting: member header, no file content, 2-block end of archive marker
346- #expect( archive. count == headerSize + trailerSize)
347- #expect( archive == emptyFile + trailer)
347+ #expect( archive. bytes . count == headerSize + trailerSize)
348+ #expect( archive. bytes == emptyFile + trailer)
348349 }
349350
350351 let helloFile : [ UInt8 ] =
@@ -456,21 +457,12 @@ let trailer = [UInt8](repeating: 0, count: trailerSize)
456457 ]
457458
458459 @Test func testAppendFile( ) async throws {
459- var archive = Archive ( )
460+ let archive = Archive ( )
460461 try archive. appendFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) )
461- let output = archive. bytes
462462
463463 // Expecting: member header, file content, 2-block end of archive marker
464- #expect( output. count == headerSize + blockSize + trailerSize)
465- #expect( output == helloFile + trailer)
466- }
467-
468- @Test func testAppendingFile( ) async throws {
469- let archive = try Archive ( ) . appendingFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) ) . bytes
470-
471- // Expecting: member header, file content, 2-block end of archive marker
472- #expect( archive. count == headerSize + blockSize + trailerSize)
473- #expect( archive == helloFile + trailer)
464+ #expect( archive. bytes. count == headerSize + blockSize + trailerSize)
465+ #expect( archive. bytes == helloFile + trailer)
474466 }
475467
476468 let directoryWithPrefix : [ UInt8 ] = [
@@ -547,47 +539,35 @@ let trailer = [UInt8](repeating: 0, count: trailerSize)
547539 ]
548540
549541 @Test func testAppendDirectory( ) async throws {
550- var archive = Archive ( )
542+ let archive = Archive ( )
551543 try archive. appendDirectory ( name: " directory " , prefix: " prefix " )
552- let output = archive. bytes
553-
554- // Expecting: member header, no content, 2-block end of archive marker
555- #expect( output. count == headerSize + trailerSize)
556- #expect( output == directoryWithPrefix + trailer)
557- }
558-
559- @Test func testAppendingDirectory( ) async throws {
560- let archive = try Archive ( ) . appendingDirectory ( name: " directory " , prefix: " prefix " ) . bytes
561544
562545 // Expecting: member header, no content, 2-block end of archive marker
563- #expect( archive. count == headerSize + trailerSize)
564- #expect( archive == directoryWithPrefix + trailer)
546+ #expect( archive. bytes . count == headerSize + trailerSize)
547+ #expect( archive. bytes == directoryWithPrefix + trailer)
565548 }
566549
567550 @Test func testAppendFilesAndDirectories( ) async throws {
568- var archive = Archive ( )
551+ let archive = Archive ( )
569552 try archive. appendFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) )
570553 try archive. appendFile ( name: " emptyfile " , data: [ UInt8] ( ) )
571554 try archive. appendDirectory ( name: " directory " , prefix: " prefix " )
572555
573- let output = archive. bytes
574-
575556 // Expecting: file member header, file content, file member header, no file content,
576557 // directory member header, 2-block end of archive marker
577- #expect( output . count == headerSize + blockSize + headerSize + headerSize + trailerSize)
578- #expect( output == helloFile + emptyFile + directoryWithPrefix + trailer)
558+ #expect( archive . bytes . count == headerSize + blockSize + headerSize + headerSize + trailerSize)
559+ #expect( archive . bytes == helloFile + emptyFile + directoryWithPrefix + trailer)
579560 }
580561
581562 @Test func testAppendingFilesAndDirectories( ) async throws {
582- let archive = try Archive ( )
583- . appendingFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) )
584- . appendingFile ( name: " emptyfile " , data: [ UInt8] ( ) )
585- . appendingDirectory ( name: " directory " , prefix: " prefix " )
586- . bytes
563+ let archive = Archive ( )
564+ try archive. appendFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) )
565+ try archive. appendFile ( name: " emptyfile " , data: [ UInt8] ( ) )
566+ try archive. appendDirectory ( name: " directory " , prefix: " prefix " )
587567
588568 // Expecting: file member header, file content, file member header, no file content,
589569 // directory member header, 2-block end of archive marker
590- #expect( archive. count == headerSize + blockSize + headerSize + headerSize + trailerSize)
591- #expect( archive == helloFile + emptyFile + directoryWithPrefix + trailer)
570+ #expect( archive. bytes . count == headerSize + blockSize + headerSize + headerSize + trailerSize)
571+ #expect( archive. bytes == helloFile + emptyFile + directoryWithPrefix + trailer)
592572 }
593573}
0 commit comments