@@ -34,29 +34,36 @@ import XCTest
3434
3535final class CommandLineArgumentsTests : XCTestCase {
3636
37- func testParseModifiers( ) throws {
38- let modifiers = try CommandLine . parseModifiers ( from: [ " --format " , " some " , " --output " , " more " , " --scale " , " magnify " , " --size " , " huge " ] )
39- XCTAssertEqual ( modifiers, [ . format: " some " , . output: " more " , . scale: " magnify " , . size: " huge " ] )
40- }
41-
42- func testParseModifiersThrowsForOddPairs( ) {
43- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " ] ) )
44- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --output " ] ) )
45- }
46-
47- func testParseModifiersThrowsForDuplicateModifiers( ) {
48- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --format " , " jpg " ] ) )
49- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --output " , " more " , " --output " , " evenmore " ] ) )
50- }
51-
52- func testParseModifiersThrowsForUnknownModifiers( ) {
53- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --unknown " , " png " ] ) )
54- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --unknown " , " more " ] ) )
55- }
56-
57- func testParseModifiersThrowsForMissingPrefix( ) {
58- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " format " , " png " ] ) )
59- XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " output " , " more " ] ) )
60- }
37+ func testParseModifiers( ) throws {
38+ var modifiers = try CommandLine . parseModifiers ( from: [ " --format " , " some " , " --output " , " more " , " --scale " , " magnify " , " --size " , " huge " ] )
39+ XCTAssertEqual ( modifiers, [ . format: " some " , . output: " more " , . scale: " magnify " , . size: " huge " ] )
40+
41+ modifiers = try CommandLine . parseModifiers ( from: [ " --ultralightInsets " , " a " , " --blackInsets " , " b " , " --hideUnsupportedFilters " , " --legacy " ] )
42+ XCTAssertEqual ( modifiers, [ . ultralightInsets: " a " , . blackInsets: " b " , . hideUnsupportedFilters: nil , . legacy: nil ] )
43+
44+ modifiers = try CommandLine . parseModifiers ( from: [ " --ultralight-insets " , " a " , " --black-insets " , " b " , " --hide-unsupported-filters " , " --legacy " ] )
45+ XCTAssertEqual ( modifiers, [ . ultralightInsets: " a " , . blackInsets: " b " , . hideUnsupportedFilters: nil , . legacy: nil ] )
46+
47+ }
48+
49+ func testParseModifiersThrowsForOddPairs( ) {
50+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " ] ) )
51+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --output " ] ) )
52+ }
53+
54+ func testParseModifiersThrowsForDuplicateModifiers( ) {
55+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --format " , " jpg " ] ) )
56+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --output " , " more " , " --output " , " evenmore " ] ) )
57+ }
58+
59+ func testParseModifiersThrowsForUnknownModifiers( ) {
60+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --unknown " , " png " ] ) )
61+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " --unknown " , " more " ] ) )
62+ }
63+
64+ func testParseModifiersThrowsForMissingPrefix( ) {
65+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " format " , " png " ] ) )
66+ XCTAssertThrowsError ( try CommandLine . parseModifiers ( from: [ " --format " , " png " , " output " , " more " ] ) )
67+ }
6168
6269}
0 commit comments