Skip to content

Commit

Permalink
Merge pull request #6 from apradanas/dev
Browse files Browse the repository at this point in the history
Add more methods and tests
  • Loading branch information
apradanas committed May 31, 2015
2 parents f9c59d1 + bc89ea6 commit 41e50a3
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 236 deletions.
8 changes: 8 additions & 0 deletions Example/SwiftArmyExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
DF3458921B16382E00BE67DE /* SwiftArmyExampleStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF3458911B16382E00BE67DE /* SwiftArmyExampleStringTests.swift */; };
DF42D3D81B16F07F00BEDF8A /* SwiftArmyExampleIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF42D3D71B16F07F00BEDF8A /* SwiftArmyExampleIntTests.swift */; };
DF42D3DA1B16F58400BEDF8A /* SwiftArmyExampleTimeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF42D3D91B16F58400BEDF8A /* SwiftArmyExampleTimeTests.swift */; };
DF942B841B18BBE000D7B6AA /* SwiftArmyExampleDoubleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF942B831B18BBE000D7B6AA /* SwiftArmyExampleDoubleTests.swift */; };
DF942B861B18BDDC00D7B6AA /* SwiftArmyExampleFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF942B851B18BDDC00D7B6AA /* SwiftArmyExampleFloatTests.swift */; };
DFC6D6961B1612F700D3E285 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFC6D6951B1612F700D3E285 /* AppDelegate.swift */; };
DFC6D6981B1612F700D3E285 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFC6D6971B1612F700D3E285 /* ViewController.swift */; };
DFC6D69B1B1612F700D3E285 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DFC6D6991B1612F700D3E285 /* Main.storyboard */; };
Expand All @@ -37,6 +39,8 @@
DF3458911B16382E00BE67DE /* SwiftArmyExampleStringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftArmyExampleStringTests.swift; sourceTree = "<group>"; };
DF42D3D71B16F07F00BEDF8A /* SwiftArmyExampleIntTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftArmyExampleIntTests.swift; sourceTree = "<group>"; };
DF42D3D91B16F58400BEDF8A /* SwiftArmyExampleTimeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftArmyExampleTimeTests.swift; sourceTree = "<group>"; };
DF942B831B18BBE000D7B6AA /* SwiftArmyExampleDoubleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftArmyExampleDoubleTests.swift; sourceTree = "<group>"; };
DF942B851B18BDDC00D7B6AA /* SwiftArmyExampleFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftArmyExampleFloatTests.swift; sourceTree = "<group>"; };
DFC6D6901B1612F700D3E285 /* SwiftArmyExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftArmyExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
DFC6D6941B1612F700D3E285 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DFC6D6951B1612F700D3E285 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -131,6 +135,8 @@
isa = PBXGroup;
children = (
DFC6D6AB1B1612F700D3E285 /* SwiftArmyExampleTests.swift */,
DF942B831B18BBE000D7B6AA /* SwiftArmyExampleDoubleTests.swift */,
DF942B851B18BDDC00D7B6AA /* SwiftArmyExampleFloatTests.swift */,
DF42D3D71B16F07F00BEDF8A /* SwiftArmyExampleIntTests.swift */,
DF3458911B16382E00BE67DE /* SwiftArmyExampleStringTests.swift */,
DF42D3D91B16F58400BEDF8A /* SwiftArmyExampleTimeTests.swift */,
Expand Down Expand Up @@ -355,7 +361,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DF942B861B18BDDC00D7B6AA /* SwiftArmyExampleFloatTests.swift in Sources */,
DF3458921B16382E00BE67DE /* SwiftArmyExampleStringTests.swift in Sources */,
DF942B841B18BBE000D7B6AA /* SwiftArmyExampleDoubleTests.swift in Sources */,
DFC6D6AC1B1612F700D3E285 /* SwiftArmyExampleTests.swift in Sources */,
DF42D3DA1B16F58400BEDF8A /* SwiftArmyExampleTimeTests.swift in Sources */,
DF42D3D81B16F07F00BEDF8A /* SwiftArmyExampleIntTests.swift in Sources */,
Expand Down
45 changes: 45 additions & 0 deletions Example/SwiftArmyExampleTests/SwiftArmyExampleDoubleTests.swift
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 Example/SwiftArmyExampleTests/SwiftArmyExampleFloatTests.swift
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))
}
}
}
}
12 changes: 12 additions & 0 deletions Example/SwiftArmyExampleTests/SwiftArmyExampleStringTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Loading

0 comments on commit 41e50a3

Please sign in to comment.