Skip to content

Commit

Permalink
Move int tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isair committed Jun 29, 2015
1 parent 46a3ce6 commit 00a6ea1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
4 changes: 4 additions & 0 deletions JSONHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -57,6 +58,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
5F024AE01B4127C900EF50C4 /* IntTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntTests.swift; sourceTree = "<group>"; };
5F0E6F961ACDE06400D92679 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -188,6 +190,7 @@
children = (
5FAD07761A70F2FC00C4D09E /* JSONHelperTests.swift */,
5FB9D4DF1B38007C00EF50C4 /* StringTests.swift */,
5F024AE01B4127C900EF50C4 /* IntTests.swift */,
5FAD07741A70F2FC00C4D09E /* Supporting Files */,
);
path = JSONHelperTests;
Expand Down Expand Up @@ -468,6 +471,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5F024AE11B4127C900EF50C4 /* IntTests.swift in Sources */,
5FB9D4E01B38007C00EF50C4 /* StringTests.swift in Sources */,
5FAD07771A70F2FC00C4D09E /* JSONHelperTests.swift in Sources */,
);
Expand Down
28 changes: 28 additions & 0 deletions JSONHelperTests/IntTests.swift
Original file line number Diff line number Diff line change
@@ -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")
}
}
31 changes: 0 additions & 31 deletions JSONHelperTests/JSONHelperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 00a6ea1

Please sign in to comment.