@@ -339,12 +339,13 @@ let trailer = [UInt8](repeating: 0, count: trailerSize)
339
339
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
340
340
]
341
341
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: [ ] )
344
345
345
346
// 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)
348
349
}
349
350
350
351
let helloFile : [ UInt8 ] =
@@ -456,21 +457,12 @@ let trailer = [UInt8](repeating: 0, count: trailerSize)
456
457
]
457
458
458
459
@Test func testAppendFile( ) async throws {
459
- var archive = Archive ( )
460
+ let archive = Archive ( )
460
461
try archive. appendFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) )
461
- let output = archive. bytes
462
462
463
463
// 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)
474
466
}
475
467
476
468
let directoryWithPrefix : [ UInt8 ] = [
@@ -547,47 +539,35 @@ let trailer = [UInt8](repeating: 0, count: trailerSize)
547
539
]
548
540
549
541
@Test func testAppendDirectory( ) async throws {
550
- var archive = Archive ( )
542
+ let archive = Archive ( )
551
543
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
561
544
562
545
// 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)
565
548
}
566
549
567
550
@Test func testAppendFilesAndDirectories( ) async throws {
568
- var archive = Archive ( )
551
+ let archive = Archive ( )
569
552
try archive. appendFile ( name: " hellofile " , data: [ UInt8] ( " hello " . utf8) )
570
553
try archive. appendFile ( name: " emptyfile " , data: [ UInt8] ( ) )
571
554
try archive. appendDirectory ( name: " directory " , prefix: " prefix " )
572
555
573
- let output = archive. bytes
574
-
575
556
// Expecting: file member header, file content, file member header, no file content,
576
557
// 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)
579
560
}
580
561
581
562
@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 " )
587
567
588
568
// Expecting: file member header, file content, file member header, no file content,
589
569
// 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)
592
572
}
593
573
}
0 commit comments