-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
416 additions
and
1,181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.conche/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
Commander.xcodeproj/project.xcworkspace/contents.xcworkspacedata
This file was deleted.
Oops, something went wrong.
100 changes: 0 additions & 100 deletions
100
Commander.xcodeproj/xcshareddata/xcschemes/Commander.xcscheme
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Spectre | ||
import Commander | ||
|
||
|
||
describe("ArgumentError") { | ||
$0.it("has a human readable description for missing value") { | ||
let error = ArgumentError.MissingValue(argument: nil) | ||
try expect(error.description) == "Missing argument" | ||
} | ||
|
||
$0.it("has a human readable description for no value") { | ||
let error = ArgumentError.InvalidType(value: "five", type: "number", argument: nil) | ||
try expect(error.description) == "`five` is not a `number`" | ||
} | ||
} | ||
|
||
describe("String ArgumentConvertible") { | ||
$0.it("converts an argument to a string value") { | ||
let parser = ArgumentParser(arguments: ["argument"]) | ||
let value = try String(parser: parser) | ||
|
||
try expect(value) == "argument" | ||
} | ||
|
||
$0.it("handles when the argument parser doesn't have any values") { | ||
let parser = ArgumentParser(arguments: []) | ||
try expect(try String(parser: parser)).toThrow(ArgumentError.MissingValue(argument: nil)) | ||
} | ||
} | ||
|
||
describe("Int ArgumentConvertible") { | ||
$0.it("converts a valid number as an integer") { | ||
let parser = ArgumentParser(arguments: ["5"]) | ||
let value = try Int(parser: parser) | ||
|
||
try expect(value) == 5 | ||
} | ||
|
||
$0.it("errors on invalid input") { | ||
let parser = ArgumentParser(arguments: ["five"]) | ||
|
||
try expect { | ||
try Int(parser: parser) | ||
}.toThrow(ArgumentError.InvalidType(value: "five", type: "number", argument: nil)) | ||
} | ||
|
||
$0.it("handles when the argument parser doesn't have any values") { | ||
let parser = ArgumentParser(arguments: []) | ||
try expect(try Int(parser: parser)).toThrow(ArgumentError.MissingValue(argument: nil)) | ||
} | ||
} | ||
|
||
describe("Float ArgumentConvertible") { | ||
$0.it("converts a valid number as an float") { | ||
let parser = ArgumentParser(arguments: ["5"]) | ||
let value = try Float(parser: parser) | ||
|
||
try expect(value) == 5 | ||
} | ||
|
||
$0.it("errors on invalid input") { | ||
let parser = ArgumentParser(arguments: ["five"]) | ||
|
||
try expect { | ||
try Float(parser: parser) | ||
}.toThrow(ArgumentError.InvalidType(value: "five", type: "number", argument: nil)) | ||
} | ||
|
||
$0.it("handles when the argument parser doesn't have any values") { | ||
let parser = ArgumentParser(arguments: []) | ||
try expect(try Float(parser: parser)).toThrow(ArgumentError.MissingValue(argument: nil)) | ||
} | ||
} | ||
|
||
describe("Double ArgumentConvertible") { | ||
$0.it("converts a valid number as an double") { | ||
let parser = ArgumentParser(arguments: ["5"]) | ||
let value = try Double(parser: parser) | ||
|
||
try expect(value) == 5 | ||
} | ||
|
||
$0.it("errors on invalid input") { | ||
let parser = ArgumentParser(arguments: ["five"]) | ||
|
||
try expect { | ||
try Double(parser: parser) | ||
}.toThrow(ArgumentError.InvalidType(value: "five", type: "number", argument: nil)) | ||
} | ||
|
||
$0.it("handles when the argument parser doesn't have any values") { | ||
let parser = ArgumentParser(arguments: []) | ||
try expect(try Double(parser: parser)).toThrow(ArgumentError.MissingValue(argument: nil)) | ||
} | ||
} |
Oops, something went wrong.