-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathCoreData.swift
41 lines (31 loc) · 1.56 KB
/
CoreData.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// RUN: %empty-directory(%t)
// RUN: %target-clang %S/Inputs/CoreDataHelper/CoreDataHelper.m -c -o %t/CoreDataHelper.o -g -fmodules
// RUN: %target-build-swift %s -import-objc-header %S/Inputs/CoreDataHelper/CoreDataHelper.h -Xlinker %t/CoreDataHelper.o -o %t/main
// RUN: %target-run %t/main
// REQUIRES: executable_test
// REQUIRES: objc_interop
import CoreData
import StdlibUnittest
var CoreDataTests = TestSuite("CoreData")
CoreDataTests.test("conformsToProtocol") {
expectTrue(NSDictionary.conforms(to: NSFetchRequestResult.self))
expectTrue(NSManagedObject.conforms(to: NSFetchRequestResult.self))
}
CoreDataTests.test("downcasting") {
var dictionaries = NSFetchRequest<NSFetchRequestResult>.testGettingSomeDictionaries()
expectType([NSFetchRequestResult].self, &dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotNil(casted)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray)
}
CoreDataTests.test("bridging") {
var dictionaries = NSFetchRequest<NSDictionary>.testGettingSomeDictionaries()
expectType([NSDictionary].self, &dictionaries)
expectEqual([[:], [:]], dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotNil(casted)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray)
}
runAllTests()