-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from apradanas/dev
Add more methods and tests
- Loading branch information
Showing
10 changed files
with
408 additions
and
236 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
45 changes: 45 additions & 0 deletions
45
Example/SwiftArmyExampleTests/SwiftArmyExampleDoubleTests.swift
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,45 @@ | ||
// | ||
// SwiftArmyExampleDoubleTests.swift | ||
// SwiftArmyExample | ||
// | ||
// Created by Aditya Pradana S. on 5/29/15. | ||
// Copyright (c) 2015 @apradanas. All rights reserved. | ||
// | ||
|
||
import SwiftArmy | ||
import Quick | ||
import Nimble | ||
|
||
class SwiftArmyExampleDoubleTests: QuickSpec { | ||
|
||
override func spec() { | ||
|
||
describe("instance methods") { | ||
|
||
it("ceil") { | ||
expect(Double(0).ceil()) == Double(0) | ||
|
||
expect(Double(99.999999).ceil()).to(beCloseTo(100, within: 0.0001)) | ||
expect(Double(99.001).ceil()).to(beCloseTo(100, within: 0.0001)) | ||
expect(Double(99.5).ceil()).to(beCloseTo(100, within: 0.0001)) | ||
|
||
expect(Double(-99.999999).ceil()).to(beCloseTo(-99, within: 0.0001)) | ||
expect(Double(-99.001).ceil()).to(beCloseTo(-99, within: 0.0001)) | ||
expect(Double(-99.5).ceil()).to(beCloseTo(-99, within: 0.0001)) | ||
} | ||
|
||
it("floor") { | ||
expect(Double(0).floor()) == Double(0) | ||
|
||
expect(Double(99.999999).floor()).to(beCloseTo(99, within: 0.0001)) | ||
expect(Double(99.001).floor()).to(beCloseTo(99, within: 0.0001)) | ||
expect(Double(99.5).floor()).to(beCloseTo(99, within: 0.0001)) | ||
|
||
expect(Double(-99.999999).floor()).to(beCloseTo(-100, within: 0.0001)) | ||
expect(Double(-99.001).floor()).to(beCloseTo(-100, within: 0.0001)) | ||
expect(Double(-99.5).floor()).to(beCloseTo(-100, within: 0.0001)) | ||
} | ||
} | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
Example/SwiftArmyExampleTests/SwiftArmyExampleFloatTests.swift
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,44 @@ | ||
// | ||
// SwiftArmyExampleFloatTests.swift | ||
// SwiftArmyExample | ||
// | ||
// Created by Aditya Pradana S. on 5/29/15. | ||
// Copyright (c) 2015 @apradanas. All rights reserved. | ||
// | ||
|
||
import SwiftArmy | ||
import Quick | ||
import Nimble | ||
|
||
class SwiftArmyExampleFloatTests: QuickSpec { | ||
|
||
override func spec() { | ||
|
||
describe("instance methods") { | ||
|
||
it("ceil") { | ||
expect(Float(0).ceil()) == Float(0) | ||
|
||
expect(Float(99.999999).ceil()).to(beCloseTo(100, within: 0.0001)) | ||
expect(Float(99.001).ceil()).to(beCloseTo(100, within: 0.0001)) | ||
expect(Float(99.5).ceil()).to(beCloseTo(100, within: 0.0001)) | ||
|
||
expect(Float(-99.99999).ceil()).to(beCloseTo(-99, within: 0.0001)) | ||
expect(Float(-99.001).ceil()).to(beCloseTo(-99, within: 0.0001)) | ||
expect(Float(-99.5).ceil()).to(beCloseTo(-99, within: 0.0001)) | ||
} | ||
|
||
it("floor") { | ||
expect(Float(0).floor()) == Float(0) | ||
|
||
expect(Float(99.99999).floor()).to(beCloseTo(99, within: 0.0001)) | ||
expect(Float(99.001).floor()).to(beCloseTo(99, within: 0.0001)) | ||
expect(Float(99.5).floor()).to(beCloseTo(99, within: 0.0001)) | ||
|
||
expect(Float(-99.999999).floor()).to(beCloseTo(-100, within: 0.0001)) | ||
expect(Float(-99.001).floor()).to(beCloseTo(-100, within: 0.0001)) | ||
expect(Float(-99.5).floor()).to(beCloseTo(-100, within: 0.0001)) | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -97,6 +97,18 @@ class SwiftArmyExampleStringTests: QuickSpec { | |
} | ||
} | ||
|
||
describe("validation") { | ||
|
||
it("isValidEmail") { | ||
expect("[email protected]".isValidEmail()).to(beTrue()) | ||
expect("[email protected]".isValidEmail()).to(beTrue()) | ||
expect("john.doe@mail".isValidEmail()).to(beFalse()) | ||
expect("john [email protected]".isValidEmail()).to(beFalse()) | ||
expect(" [email protected]".isValidEmail()).to(beFalse()) | ||
expect("[email protected] ".isValidEmail()).to(beFalse()) | ||
} | ||
} | ||
|
||
describe("conversion") { | ||
|
||
it("toDouble") { | ||
|
Oops, something went wrong.