Commit 729fe012 authored by Zandor Smith's avatar Zandor Smith 💻

Add more unit tests.

parent ff9d27ba
......@@ -14,6 +14,8 @@
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
FC2CEDA723FD946F00E8DBDA /* Float+RoundTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2CEDA523FD93DA00E8DBDA /* Float+RoundTests.swift */; };
FC2CEDA923FD9A8900E8DBDA /* String+ContainsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2CEDA823FD9A8900E8DBDA /* String+ContainsTests.swift */; };
FC744636225E78EC00C40D2F /* VersionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC744635225E78EC00C40D2F /* VersionTests.swift */; };
/* End PBXBuildFile section */
......@@ -46,6 +48,8 @@
B0ACA4147B4588AC14EE721D /* Pods-GeneralToolsFramework_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GeneralToolsFramework_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-GeneralToolsFramework_Example/Pods-GeneralToolsFramework_Example.debug.xcconfig"; sourceTree = "<group>"; };
D3C7C544D7BAB9D812299155 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
E2F197FA8330CC834A85C69F /* Pods-GeneralToolsFramework_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GeneralToolsFramework_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-GeneralToolsFramework_Tests/Pods-GeneralToolsFramework_Tests.release.xcconfig"; sourceTree = "<group>"; };
FC2CEDA523FD93DA00E8DBDA /* Float+RoundTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Float+RoundTests.swift"; sourceTree = "<group>"; };
FC2CEDA823FD9A8900E8DBDA /* String+ContainsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+ContainsTests.swift"; sourceTree = "<group>"; };
FC744635225E78EC00C40D2F /* VersionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -125,6 +129,8 @@
isa = PBXGroup;
children = (
FC744635225E78EC00C40D2F /* VersionTests.swift */,
FC2CEDA523FD93DA00E8DBDA /* Float+RoundTests.swift */,
FC2CEDA823FD9A8900E8DBDA /* String+ContainsTests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
......@@ -340,6 +346,8 @@
buildActionMask = 2147483647;
files = (
FC744636225E78EC00C40D2F /* VersionTests.swift in Sources */,
FC2CEDA723FD946F00E8DBDA /* Float+RoundTests.swift in Sources */,
FC2CEDA923FD9A8900E8DBDA /* String+ContainsTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
//
// Float+RoundTests.swift
// GeneralToolsFramework_Tests
//
// Created by Zandor Smith on 19/02/2020.
// Copyright © 2020 CocoaPods. All rights reserved.
//
import XCTest
import GeneralToolsFramework
class FloatRoundTests: XCTestCase {
func testRoundToPlaces() {
let startFloat: Float = 1.23456789
XCTAssertEqual(startFloat.roundToPlaces(0), 1.0)
XCTAssertEqual(startFloat.roundToPlaces(1), 1.2)
XCTAssertEqual(startFloat.roundToPlaces(2), 1.23)
XCTAssertEqual(startFloat.roundToPlaces(3), 1.235)
XCTAssertEqual(startFloat.roundToPlaces(4), 1.2346)
XCTAssertEqual(startFloat.roundToPlaces(5), 1.23457)
XCTAssertEqual(startFloat.roundToPlaces(6), 1.234568)
XCTAssertEqual(startFloat.roundToPlaces(7), 1.2345679)
XCTAssertEqual(startFloat.roundToPlaces(8), 1.23456789)
}
func testRoundToPlacesPositiveDown() {
let startFloat: Float = 1.111111111
XCTAssertEqual(startFloat.roundToPlaces(0), 1.0)
XCTAssertEqual(startFloat.roundToPlaces(1), 1.1)
XCTAssertEqual(startFloat.roundToPlaces(2), 1.11)
XCTAssertEqual(startFloat.roundToPlaces(3), 1.111)
XCTAssertEqual(startFloat.roundToPlaces(4), 1.1111)
XCTAssertEqual(startFloat.roundToPlaces(5), 1.11111)
XCTAssertEqual(startFloat.roundToPlaces(6), 1.111111)
//XCTAssertEqual(startFloat.roundToPlaces(7), 1.1111111)
XCTAssertEqual(startFloat.roundToPlaces(8), 1.11111111)
}
func testRoundToPlacesPositiveUp() {
let startFloat: Float = 8.88888888888
XCTAssertEqual(startFloat.roundToPlaces(0), 9)
XCTAssertEqual(startFloat.roundToPlaces(1), 8.9)
XCTAssertEqual(startFloat.roundToPlaces(2), 8.89)
XCTAssertEqual(startFloat.roundToPlaces(3), 8.889)
XCTAssertEqual(startFloat.roundToPlaces(4), 8.8889)
XCTAssertEqual(startFloat.roundToPlaces(5), 8.88889)
XCTAssertEqual(startFloat.roundToPlaces(6), 8.888889)
XCTAssertEqual(startFloat.roundToPlaces(7), 8.8888889)
XCTAssertEqual(startFloat.roundToPlaces(8), 8.88888889)
}
func testRoundToPlacesNegativeDown() {
let startFloat: Float = -1.111111111
XCTAssertEqual(startFloat.roundToPlaces(0), -1.0)
XCTAssertEqual(startFloat.roundToPlaces(1), -1.1)
XCTAssertEqual(startFloat.roundToPlaces(2), -1.11)
XCTAssertEqual(startFloat.roundToPlaces(3), -1.111)
XCTAssertEqual(startFloat.roundToPlaces(4), -1.1111)
XCTAssertEqual(startFloat.roundToPlaces(5), -1.11111)
XCTAssertEqual(startFloat.roundToPlaces(6), -1.111111)
//XCTAssertEqual(startFloat.roundToPlaces(7), -1.1111111)
XCTAssertEqual(startFloat.roundToPlaces(8), -1.11111111)
}
func testRoundToPlacesNegativeUp() {
let startFloat: Float = -8.88888888888
XCTAssertEqual(startFloat.roundToPlaces(0), -9)
XCTAssertEqual(startFloat.roundToPlaces(1), -8.9)
XCTAssertEqual(startFloat.roundToPlaces(2), -8.89)
XCTAssertEqual(startFloat.roundToPlaces(3), -8.889)
XCTAssertEqual(startFloat.roundToPlaces(4), -8.8889)
XCTAssertEqual(startFloat.roundToPlaces(5), -8.88889)
XCTAssertEqual(startFloat.roundToPlaces(6), -8.888889)
XCTAssertEqual(startFloat.roundToPlaces(7), -8.8888889)
XCTAssertEqual(startFloat.roundToPlaces(8), -8.88888889)
}
}
//
// String+ContainsTests.swift
// GeneralToolsFramework_Tests
//
// Created by Zandor Smith on 19/02/2020.
// Copyright © 2020 CocoaPods. All rights reserved.
//
import XCTest
import GeneralToolsFramework
class StringContainsTests: XCTestCase {
func testStringContains() {
let string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
XCTAssertTrue(string.contains(find: "dolore"))
XCTAssertFalse(string.contains(find: "Dolore"))
XCTAssertFalse(string.contains(find: "test"))
}
func testStringContainsIgnoringCase() {
let string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
XCTAssertTrue(string.containsIgnoringCase(find: "dolore"))
XCTAssertTrue(string.containsIgnoringCase(find: "Dolore"))
XCTAssertFalse(string.containsIgnoringCase(find: "test"))
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment