-
Notifications
You must be signed in to change notification settings - Fork 17
Change to keyIsEmpty function. It will now comply with optional variables. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1cbb94d
Adding in the changes to consider optionals when checking if the keyI…
ryancoyne 4ee391d
Modifying print statement for an unexpected type for primary keys
ryancoyne 93abd26
Writing some tests against for the new keyIsEmpty function
ryancoyne a9a532d
Removed out the old commented code
ryancoyne d86a081
Merge remote-tracking branch 'upstream/master'
ryancoyne 20319cf
Merged upstream/master & added in minor changes to test file for cons…
ryancoyne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
// | ||
// Package.swift | ||
// StORM | ||
// | ||
// Created by Jonathan Guthrie on 2016-09-23. | ||
// Copyright (C) 2016 Jonathan Guthrie. | ||
// | ||
|
||
// Generated automatically by Perfect Assistant Application | ||
// Date: 2017-08-13 18:42:55 +0000 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "StORM", | ||
targets: [], | ||
dependencies: [ | ||
.Package(url: "https://github.com/PerfectlySoft/PerfectLib.git", majorVersion: 2) | ||
], | ||
exclude: [] | ||
.Package(url: "https://github.com/PerfectlySoft/PerfectLib.git", majorVersion: 2), | ||
] | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,113 @@ class StORMTests: XCTestCase { | |
override func setUp() { | ||
super.setUp() | ||
} | ||
|
||
func testKeyTypeIntegerNil() { | ||
|
||
let val : Int?=nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor formatting for consistency |
||
|
||
// Grab the type of value: | ||
let type = type(of: val) | ||
// Check if we are nil, we would then of course have an empty primary key. | ||
|
||
switch type { | ||
case is Int.Type, is Int?.Type: | ||
guard String(describing: val) != "nil" else { | ||
XCTAssert(true) | ||
return | ||
} | ||
XCTFail("Value was supposed to be nil.") | ||
// return (val as! Int == 0) | ||
case is String.Type, is String?.Type: | ||
// return (val as! String).isEmpty | ||
XCTFail("Type was supposed to be an integer.") | ||
default: | ||
XCTFail("Type should either be a String or Integer.") | ||
print("[StORM] WARNING: Unexpected type for PRIMARY KEY in function: \(#function). TYPE: \(type)") | ||
// return false | ||
} | ||
|
||
} | ||
|
||
func testKeyTypeOptionalInteger() { | ||
|
||
|
||
let val : Int? = 1 | ||
|
||
let anyVal : Any = val | ||
|
||
// Grab the type of value: | ||
let type = type(of: val) | ||
// Check if we are nil, we would then of course have an empty primary key. | ||
guard String(describing: anyVal) != "nil" else { | ||
XCTFail("Value was not supposed to be nil.") | ||
return | ||
} | ||
|
||
switch type { | ||
case is Int.Type, is Int?.Type: | ||
XCTAssert((anyVal as? Int) != nil, "Failed to cast optional Integer as Any to Int") | ||
// return (val as! Int == 0) | ||
case is String.Type, is String?.Type: | ||
// return (val as! String).isEmpty | ||
XCTFail("Type was supposed to be an integer.") | ||
default: | ||
XCTFail("Type should either be a String or Integer.") | ||
print("[StORM] WARNING: Unexpected type for PRIMARY KEY in function: \(#function). TYPE: \(type)") | ||
// return false | ||
} | ||
|
||
} | ||
|
||
func testKeyTypeStringNil() { | ||
|
||
let val : String?=nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor formatting for consistency |
||
|
||
// Grab the type of value: | ||
let type = type(of: val) | ||
|
||
switch type { | ||
case is Int.Type, is Int?.Type: | ||
XCTFail("Type was supposed to be a string.") | ||
case is String.Type, is String?.Type: | ||
guard String(describing: val) != "nil" else { | ||
XCTAssert(true) | ||
return | ||
} | ||
XCTFail("Value was supposed to be nil.") | ||
default: | ||
XCTFail("Type should either be a String or Integer.") | ||
print("[StORM] WARNING: Unexpected type for PRIMARY KEY in function: \(#function). TYPE: \(type)") | ||
} | ||
|
||
} | ||
|
||
func testKeyTypeOptionalString() { | ||
|
||
|
||
let val : String? = "" | ||
|
||
let anyVal : Any = val | ||
|
||
// Grab the type of value: | ||
let type = type(of: val) | ||
// Check if we are nil, we would then of course have an empty primary key. | ||
guard String(describing: anyVal) != "nil" else { | ||
XCTFail("Value was not supposed to be nil.") | ||
return | ||
} | ||
|
||
switch type { | ||
case is Int.Type, is Int?.Type: | ||
XCTFail("Type was supposed to be a string.") | ||
case is String.Type, is String?.Type: | ||
XCTAssert((anyVal as? String) != nil, "Failed to cast optional string as Any to String") | ||
default: | ||
XCTFail("Type should either be a String or Integer.") | ||
print("[StORM] WARNING: Unexpected type for PRIMARY KEY in function: \(#function). TYPE: \(type)") | ||
} | ||
|
||
} | ||
|
||
static var allTests : [(String, (StORMTests) -> () throws -> Void)] { | ||
return [ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest removing unused code unless it will be needed in the near future.