From 976f71e47e1ad73a13ca65cecce43f0bb1505687 Mon Sep 17 00:00:00 2001 From: Wim Haanstra Date: Mon, 18 Jan 2016 11:21:18 +0100 Subject: [PATCH] Added more test Added tests for: - UIViewTintAdjustmentModeConverter - CGRectConverter - BoolConverter --- pixelbits.xcodeproj/project.pbxproj | 12 +++++ pixelbitsTests/BoolConverterTest.swift | 33 +++++++++++++ pixelbitsTests/CGRectConverterTest.swift | 49 +++++++++++++++++++ ...IViewTintAdjustmentModeConverterTest.swift | 30 ++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 pixelbitsTests/BoolConverterTest.swift create mode 100644 pixelbitsTests/CGRectConverterTest.swift create mode 100644 pixelbitsTests/UIViewTintAdjustmentModeConverterTest.swift diff --git a/pixelbits.xcodeproj/project.pbxproj b/pixelbits.xcodeproj/project.pbxproj index 37a46fd..89b8bd5 100755 --- a/pixelbits.xcodeproj/project.pbxproj +++ b/pixelbits.xcodeproj/project.pbxproj @@ -13,6 +13,9 @@ AB1243341C4CA7CF009F29E8 /* IConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1243331C4CA7CF009F29E8 /* IConverter.swift */; }; AB1243361C4CBA2F009F29E8 /* BooleanConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1243351C4CBA2F009F29E8 /* BooleanConverter.swift */; }; AB12433A1C4CD261009F29E8 /* CGRectConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1243391C4CD261009F29E8 /* CGRectConverter.swift */; }; + AB1243401C4CF204009F29E8 /* BoolConverterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB12433F1C4CF204009F29E8 /* BoolConverterTest.swift */; }; + AB1243421C4CF2B2009F29E8 /* UIViewTintAdjustmentModeConverterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1243411C4CF2B2009F29E8 /* UIViewTintAdjustmentModeConverterTest.swift */; }; + AB1243441C4CF369009F29E8 /* CGRectConverterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1243431C4CF369009F29E8 /* CGRectConverterTest.swift */; }; AB35DD421C45093600E60F32 /* UIViewLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB35DD411C45093600E60F32 /* UIViewLocation.swift */; }; AB35DD441C46675400E60F32 /* PBNodeCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB35DD431C46675400E60F32 /* PBNodeCollection.swift */; }; AB35DD461C467BA300E60F32 /* Array+remove.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB35DD451C467BA300E60F32 /* Array+remove.swift */; }; @@ -71,6 +74,9 @@ AB1243331C4CA7CF009F29E8 /* IConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IConverter.swift; sourceTree = ""; }; AB1243351C4CBA2F009F29E8 /* BooleanConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BooleanConverter.swift; sourceTree = ""; }; AB1243391C4CD261009F29E8 /* CGRectConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGRectConverter.swift; sourceTree = ""; }; + AB12433F1C4CF204009F29E8 /* BoolConverterTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoolConverterTest.swift; sourceTree = ""; }; + AB1243411C4CF2B2009F29E8 /* UIViewTintAdjustmentModeConverterTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewTintAdjustmentModeConverterTest.swift; sourceTree = ""; }; + AB1243431C4CF369009F29E8 /* CGRectConverterTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGRectConverterTest.swift; sourceTree = ""; }; AB35DD411C45093600E60F32 /* UIViewLocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewLocation.swift; sourceTree = ""; }; AB35DD431C46675400E60F32 /* PBNodeCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PBNodeCollection.swift; sourceTree = ""; }; AB35DD451C467BA300E60F32 /* Array+remove.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Array+remove.swift"; path = "Extensions/Array+remove.swift"; sourceTree = ""; }; @@ -210,6 +216,9 @@ AB7C54DB1C48B681005FDF1B /* pixelbitsTests */ = { isa = PBXGroup; children = ( + AB1243431C4CF369009F29E8 /* CGRectConverterTest.swift */, + AB1243411C4CF2B2009F29E8 /* UIViewTintAdjustmentModeConverterTest.swift */, + AB12433F1C4CF204009F29E8 /* BoolConverterTest.swift */, ABB440391C494381009028B8 /* ArrayExtensionTest.swift */, ABB440331C490A78009028B8 /* DictionaryKeyConverterTest.swift */, AB7C54DE1C48B681005FDF1B /* Info.plist */, @@ -403,11 +412,14 @@ ABB4402C1C48F60C009028B8 /* UIControlContentHorizontalAlignmentConverterTest.swift in Sources */, ABB440381C494257009028B8 /* UIViewExtensionTest.swift in Sources */, ABB4403E1C4990AC009028B8 /* UIViewContentModeConverterTest.swift in Sources */, + AB1243401C4CF204009F29E8 /* BoolConverterTest.swift in Sources */, AB7C54E61C48B6CC005FDF1B /* pathFindingTests.swift in Sources */, + AB1243441C4CF369009F29E8 /* CGRectConverterTest.swift in Sources */, ABB440361C4915A9009028B8 /* UIFontConverterTest.swift in Sources */, ABB4402A1C48F571009028B8 /* UIControlContentVerticalAlignmentConverterTest.swift in Sources */, ABB440301C490875009028B8 /* UIImageConverterTest.swift in Sources */, ABB440401C4992EE009028B8 /* ValueToPropertyConverterTest.swift in Sources */, + AB1243421C4CF2B2009F29E8 /* UIViewTintAdjustmentModeConverterTest.swift in Sources */, AB1243321C4B78D3009F29E8 /* UIEdgeInsetsConverterTest.swift in Sources */, ABB440281C48EF79009028B8 /* NSTextAlignmentConverterTest.swift in Sources */, ABB440261C48E946009028B8 /* UIColorConverterTest.swift in Sources */, diff --git a/pixelbitsTests/BoolConverterTest.swift b/pixelbitsTests/BoolConverterTest.swift new file mode 100644 index 0000000..70e2e76 --- /dev/null +++ b/pixelbitsTests/BoolConverterTest.swift @@ -0,0 +1,33 @@ +// +// BoolConverterTest.swift +// pixelbits +// +// Created by Wim Haanstra on 18/01/16. +// Copyright © 2016 Wim Haanstra. All rights reserved. +// + +import XCTest +@testable import pixelbits + +class BoolConverterTest: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testValidBoolValue() { + + XCTAssertEqual(BooleanConverter.fromString("true"), true) + XCTAssertEqual(BooleanConverter.fromString("yes"), true) + XCTAssertEqual(BooleanConverter.fromString("false"), false) + XCTAssertEqual(BooleanConverter.fromString("no"), false) + + } + +} diff --git a/pixelbitsTests/CGRectConverterTest.swift b/pixelbitsTests/CGRectConverterTest.swift new file mode 100644 index 0000000..60fd3d4 --- /dev/null +++ b/pixelbitsTests/CGRectConverterTest.swift @@ -0,0 +1,49 @@ +// +// CGRectConverterTest.swift +// pixelbits +// +// Created by Wim Haanstra on 18/01/16. +// Copyright © 2016 Wim Haanstra. All rights reserved. +// + +import XCTest +@testable import pixelbits + +class CGRectConverterTest: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testSingleValue() { + + XCTAssertEqual(CGRectConverter.fromString("rect(4)"), NSValue(CGRect: CGRectMake(4, 4, 4, 4))) + XCTAssertEqual(CGRectConverter.fromString("rect(4.25)"), NSValue(CGRect: CGRectMake(4.25, 4.25, 4.25, 4.25))) + + } + + func testDoubleValue() { + XCTAssertEqual(CGRectConverter.fromString("rect(4, 5)"), NSValue(CGRect: CGRectMake(4, 5, 4, 5))) + XCTAssertEqual(CGRectConverter.fromString("rect(4.25, 2.5)"), NSValue(CGRect: CGRectMake(4.25, 2.5, 4.25, 2.5))) + } + + func testFull() { + XCTAssertEqual(CGRectConverter.fromString("rect(4, 5,6, 7)"), NSValue(CGRect: CGRectMake(4, 5, 6, 7))) + XCTAssertEqual(CGRectConverter.fromString("rect(4.25, 5.30,6.4, 7.5)"), NSValue(CGRect: CGRectMake(4.25, 5.3, 6.4, 7.5))) + } + + func testInvalid() { + XCTAssertNil(CGRectConverter.fromString("rect(stringvalue)")) + XCTAssertNil(CGRectConverter.fromString("rect(4,stringvalue)")) + XCTAssertNil(CGRectConverter.fromString("rect(4,4,4)")) + XCTAssertNil(CGRectConverter.fromString("rect(4,stringvalue,4)")) + + } + +} diff --git a/pixelbitsTests/UIViewTintAdjustmentModeConverterTest.swift b/pixelbitsTests/UIViewTintAdjustmentModeConverterTest.swift new file mode 100644 index 0000000..eb80a5b --- /dev/null +++ b/pixelbitsTests/UIViewTintAdjustmentModeConverterTest.swift @@ -0,0 +1,30 @@ +// +// UIViewTintAdjustmentModeConverterTest.swift +// pixelbits +// +// Created by Wim Haanstra on 18/01/16. +// Copyright © 2016 Wim Haanstra. All rights reserved. +// + +import XCTest +@testable import pixelbits + +class UIViewTintAdjustmentModeConverterTest: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testFromString() { + XCTAssertEqual(UIViewTintAdjustmentModeConverter.fromString("UIViewTintAdjustmentModeAutomatic"), UIViewTintAdjustmentMode.Automatic) + XCTAssertEqual(UIViewTintAdjustmentModeConverter.fromString("UIViewTintAdjustmentModeNormal"), UIViewTintAdjustmentMode.Normal) + XCTAssertEqual(UIViewTintAdjustmentModeConverter.fromString("UIViewTintAdjustmentModeDimmed"), UIViewTintAdjustmentMode.Dimmed) + } + +}