From 00a6ea1526e66d0d77af092b47da5175efae8375 Mon Sep 17 00:00:00 2001 From: Baris Sencan Date: Mon, 29 Jun 2015 00:19:29 -0700 Subject: [PATCH] Move int tests --- JSONHelper.xcodeproj/project.pbxproj | 4 ++++ JSONHelperTests/IntTests.swift | 28 ++++++++++++++++++++++++ JSONHelperTests/JSONHelperTests.swift | 31 --------------------------- 3 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 JSONHelperTests/IntTests.swift diff --git a/JSONHelper.xcodeproj/project.pbxproj b/JSONHelper.xcodeproj/project.pbxproj index 670abb9..aa448c4 100644 --- a/JSONHelper.xcodeproj/project.pbxproj +++ b/JSONHelper.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 5F024AE11B4127C900EF50C4 /* IntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F024AE01B4127C900EF50C4 /* IntTests.swift */; }; 5FAD076A1A70F2FC00C4D09E /* JSONHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FAD07691A70F2FC00C4D09E /* JSONHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5FAD07701A70F2FC00C4D09E /* JSONHelper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5FAD07641A70F2FC00C4D09E /* JSONHelper.framework */; }; 5FAD07771A70F2FC00C4D09E /* JSONHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FAD07761A70F2FC00C4D09E /* JSONHelperTests.swift */; }; @@ -57,6 +58,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 5F024AE01B4127C900EF50C4 /* IntTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntTests.swift; sourceTree = ""; }; 5F0E6F961ACDE06400D92679 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5FAD07641A70F2FC00C4D09E /* JSONHelper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JSONHelper.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5FAD07681A70F2FC00C4D09E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -188,6 +190,7 @@ children = ( 5FAD07761A70F2FC00C4D09E /* JSONHelperTests.swift */, 5FB9D4DF1B38007C00EF50C4 /* StringTests.swift */, + 5F024AE01B4127C900EF50C4 /* IntTests.swift */, 5FAD07741A70F2FC00C4D09E /* Supporting Files */, ); path = JSONHelperTests; @@ -468,6 +471,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5F024AE11B4127C900EF50C4 /* IntTests.swift in Sources */, 5FB9D4E01B38007C00EF50C4 /* StringTests.swift in Sources */, 5FAD07771A70F2FC00C4D09E /* JSONHelperTests.swift in Sources */, ); diff --git a/JSONHelperTests/IntTests.swift b/JSONHelperTests/IntTests.swift new file mode 100644 index 0000000..3b56038 --- /dev/null +++ b/JSONHelperTests/IntTests.swift @@ -0,0 +1,28 @@ +// +// IntTests.swift +// JSONHelper +// +// Created by Baris Sencan on 6/29/15. +// Copyright (c) 2015 Baris Sencan. All rights reserved. +// + +import Foundation +import XCTest +import JSONHelper + +class IntTests: XCTestCase { + let testInt = 1 + let testString = "1" + + func testIntToIntConversion() { + var value: Int? + value <-- (testInt as Any) + XCTAssertEqual(value!, testInt, "Int to Int conversion failed") + } + + func testStringToIntConversion() { + var value: Int? + value <-- (testString as Any) + XCTAssertEqual(value!, testInt, "String to Int conversion failed") + } +} diff --git a/JSONHelperTests/JSONHelperTests.swift b/JSONHelperTests/JSONHelperTests.swift index 4652178..b34a908 100644 --- a/JSONHelperTests/JSONHelperTests.swift +++ b/JSONHelperTests/JSONHelperTests.swift @@ -12,9 +12,6 @@ import JSONHelper class JSONHelperTests: XCTestCase { let dummyResponse: JSONDictionary = [ - "string": "a", - "int": 1, - "int_string": "1", "bool": true, "date": "2014-09-19", "url": "http://github.com/", @@ -56,34 +53,6 @@ class JSONHelperTests: XCTestCase { case One = 1 } - func testOptionalInt() { - var property: Int? - property <-- dummyResponse["int"] - XCTAssertEqual(property!, 1, "Int? property should equal 1") - property <-- dummyResponse["invalidKey"] - XCTAssertNil(property, "Int? property should equal nil after invalid assignment") - } - - func testInt() { - var property = 2 - property <-- dummyResponse["invalidKey"] - XCTAssertEqual(property, 2, "Int property should have the default value 2") - property <-- dummyResponse["int"] - XCTAssertEqual(property, 1, "Int property should equal 1") - } - - func testStringToOptionalInt() { - var number: Int? - number <-- dummyResponse["int_string"] - XCTAssertEqual(number!, 1, "Strings containing numbers should successfully deserialize into optional Ints.") - } - - func testStringToInt() { - var number = 0 - number <-- dummyResponse["int_string"] - XCTAssertEqual(number, 1, "Strings containing numbers should successfully deserialize into Ints.") - } - func testOptionalBool() { var property: Bool? property <-- dummyResponse["bool"]