-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up test suite to pass on both ObjC & Swift
- Loading branch information
Showing
12 changed files
with
149 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
// Mostly stolen from http://abcnewsgocom/blogs/headlines/2014/02/heres-a-list-of-58-gender-options-for-facebook-users/ | ||
enum Gender: Int32 { | ||
case Undefined = 0, | ||
Female, | ||
Male, | ||
Other, | ||
Agender, | ||
Androgyne, | ||
Androgynous, | ||
Bigender, | ||
Cisgender, | ||
CisgenderFemale, | ||
CisgenderMale, | ||
FemaleToMale, | ||
GenderFluid, | ||
GenderNonconforming, | ||
GenderQuestioning, | ||
GenderVariant, | ||
Genderqueer, | ||
Intersex, | ||
MaleToFemale, | ||
Neither, | ||
Neutrois, | ||
Nonbinary, | ||
Pangender, | ||
Trans, | ||
TransStar, | ||
TransFemale, | ||
TransStarFemale, | ||
TransMale, | ||
TransStarMale, | ||
TransPerson, | ||
TransStarPerson, | ||
Transfeminine, | ||
Transgender, | ||
TransgenderFemale, | ||
TransgenderMale, | ||
TransgenderPerson, | ||
Transmasculine, | ||
Transsexual, | ||
TranssexualFemale, | ||
TranssexualMale, | ||
TranssexualPerson | ||
|
||
func toString() -> String { | ||
return String(self) | ||
} | ||
} | ||
|
||
func ==(lhs: Gender, rhs: Gender) -> Bool { | ||
return lhs.rawValue == rhs.rawValue | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
import CoreData | ||
|
||
public class MyBaseClass: NSManagedObject { | ||
var ivar: Double = -1.0 | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Cocoa | ||
import CoreData | ||
|
||
struct CoreDataStore { | ||
let moc: NSManagedObjectContext | ||
|
||
init() { | ||
let modelURL = NSURL(fileURLWithPath: "test.mom") | ||
let model = NSManagedObjectModel(contentsOfURL: modelURL) | ||
let psc = NSPersistentStoreCoordinator(managedObjectModel: model!) | ||
|
||
do { | ||
try psc.addPersistentStoreWithType(NSInMemoryStoreType, configuration: nil, URL: nil, options: nil) | ||
} catch { | ||
assertionFailure("Can't bring up PSC") | ||
} | ||
|
||
moc = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType) | ||
moc.persistentStoreCoordinator = psc | ||
} | ||
} | ||
|
||
let dataStore = CoreDataStore() | ||
let moc = dataStore.moc | ||
|
||
let homer = ParentMO(managedObjectContext: moc)! | ||
homer.humanName = "homer" | ||
homer.parentName = homer.humanName | ||
homer.ivar = 1.0 | ||
homer.gender = NSNumber(int: Gender.Male.rawValue) | ||
|
||
let marge = ParentMO(managedObjectContext: moc)! | ||
marge.humanName = "marge" | ||
marge.parentName = marge.humanName | ||
marge.ivar = 1.0 | ||
marge.gender = NSNumber(int: Gender.Female.rawValue) | ||
|
||
assert(homer.children.count == 0) | ||
assert(marge.children.count == 0) | ||
|
||
let bart = ChildMO(managedObjectContext: moc)! | ||
bart.humanName = "bart" | ||
bart.childName = bart.humanName | ||
bart.ivar = 1.0 | ||
bart.type = 64 | ||
|
||
let lisa = ChildMO(managedObjectContext: moc)! | ||
lisa.humanName = "lisa" | ||
lisa.childName = lisa.humanName | ||
lisa.ivar = 1.0 | ||
|
||
do { | ||
try moc.save() | ||
assert(Gender(rawValue: homer.gender!.intValue) == .Male) | ||
assert(Gender(rawValue: marge.gender!.intValue) == .Female) | ||
assert(Gender(rawValue: bart.gender!.intValue) == .Undefined) | ||
assert(Gender(rawValue: homer.gender!.intValue)!.toString() == "Male") | ||
|
||
} catch { | ||
assertionFailure("Failed to save") | ||
} | ||
|
||
print("Success") |
This file contains 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