move type safety goodness

This commit is contained in:
John Estropia
2017-02-21 19:17:06 +09:00
parent 9ff1c9d545
commit 3224fcf71d
9 changed files with 732 additions and 608 deletions

View File

@@ -868,6 +868,24 @@ final class FetchTests: BaseTestDataTestCase {
}
XCTAssertNil(objects)
let objectIDs = self.expectLogger([.logWarning]) {
stack.fetchObjectIDs(from, fetchClauses)
}
XCTAssertNil(objectIDs)
}
do {
let fetchClauses: [FetchClause] = [
Where(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
OrderBy(.descending(#keyPath(TestEntity1.testEntityID)))
]
let objects = self.expectLogger([.logWarning]) {
stack.fetchAll(from, fetchClauses)
}
XCTAssertNil(objects)
let objectIDs = self.expectLogger([.logWarning]) {
stack.fetchObjectIDs(from, fetchClauses)
@@ -1445,6 +1463,18 @@ final class FetchTests: BaseTestDataTestCase {
}
XCTAssertNil(count)
}
do {
let count = self.expectLogger([.logWarning]) {
stack.fetchCount(
from,
Where(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
OrderBy(.descending(#keyPath(TestEntity1.testEntityID)))
)
}
XCTAssertNil(count)
}
}
}
}
@@ -1592,6 +1622,18 @@ final class FetchTests: BaseTestDataTestCase {
}
XCTAssertNil(count)
}
do {
let count = self.expectLogger([.logWarning]) {
stack.fetchCount(
from,
Where(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
OrderBy(.descending(#keyPath(TestEntity1.testEntityID)))
)
}
XCTAssertNil(count)
}
}
}
}
@@ -2361,6 +2403,24 @@ final class FetchTests: BaseTestDataTestCase {
}
XCTAssertNil(objects)
let objectIDs = self.expectLogger([.logWarning]) {
transaction.fetchObjectIDs(from, fetchClauses)
}
XCTAssertNil(objectIDs)
}
do {
let fetchClauses: [FetchClause] = [
Where(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
OrderBy(.descending(#keyPath(TestEntity1.testEntityID)))
]
let objects = self.expectLogger([.logWarning]) {
transaction.fetchAll(from, fetchClauses)
}
XCTAssertNil(objects)
let objectIDs = self.expectLogger([.logWarning]) {
transaction.fetchObjectIDs(from, fetchClauses)
@@ -2938,6 +2998,18 @@ final class FetchTests: BaseTestDataTestCase {
}
XCTAssertNil(count)
}
do {
let count = self.expectLogger([.logWarning]) {
transaction.fetchCount(
from,
Where(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
OrderBy(.descending(#keyPath(TestEntity1.testEntityID)))
)
}
XCTAssertNil(count)
}
}
}
}
@@ -3085,6 +3157,18 @@ final class FetchTests: BaseTestDataTestCase {
}
XCTAssertNil(count)
}
do {
let count = self.expectLogger([.logWarning]) {
transaction.fetchCount(
from,
Where(#keyPath(TestEntity1.testNumber), isEqualTo: nil),
OrderBy(.descending(#keyPath(TestEntity1.testEntityID)))
)
}
XCTAssertNil(count)
}
}
}
}

View File

@@ -36,40 +36,40 @@ class ImportTests: BaseTestDataTestCase {
@objc
dynamic func test_ThatAttributeProtocols_BehaveCorrectly() {
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: true))?.boolValue, true)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int16.max))?.int16Value, Int16.max)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int32.max))?.int32Value, Int32.max)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int64.max))?.int64Value, Int64.max)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: MAXFLOAT))?.floatValue, MAXFLOAT)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Double(MAXFLOAT)))?.doubleValue, Double(MAXFLOAT))
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSNumber(value: true))?.boolValue, true)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSNumber(value: Int16.max))?.int16Value, Int16.max)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSNumber(value: Int32.max))?.int32Value, Int32.max)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSNumber(value: Int64.max))?.int64Value, Int64.max)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSNumber(value: MAXFLOAT))?.floatValue, MAXFLOAT)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSNumber(value: Double(MAXFLOAT)))?.doubleValue, Double(MAXFLOAT))
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
XCTAssertEqual(NSDecimalNumber.cs_fromImportableNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
XCTAssertEqual(NSDecimalNumber.cs_fromImportableNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
XCTAssertEqual(NSDecimalNumber.cs_fromImportableNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
XCTAssertEqual(NSDecimalNumber.cs_fromImportableNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
XCTAssertEqual(NSDecimalNumber.cs_fromImportableNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
XCTAssertEqual(NSDecimalNumber.cs_fromImportableNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
XCTAssertEqual(NSNumber.cs_fromImportableNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: true)))
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int16.max)))
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int32.max)))
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int64.max)))
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: MAXFLOAT)))
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Double(MAXFLOAT))))
XCTAssertNil(NSDecimalNumber.cs_fromImportableNativeType(NSNumber(value: true)))
XCTAssertNil(NSDecimalNumber.cs_fromImportableNativeType(NSNumber(value: Int16.max)))
XCTAssertNil(NSDecimalNumber.cs_fromImportableNativeType(NSNumber(value: Int32.max)))
XCTAssertNil(NSDecimalNumber.cs_fromImportableNativeType(NSNumber(value: Int64.max)))
XCTAssertNil(NSDecimalNumber.cs_fromImportableNativeType(NSNumber(value: MAXFLOAT)))
XCTAssertNil(NSDecimalNumber.cs_fromImportableNativeType(NSNumber(value: Double(MAXFLOAT))))
XCTAssertEqual(true.cs_toUniqueIDNativeType(), NSNumber(value: true))
XCTAssertEqual(Int16.max.cs_toUniqueIDNativeType(), NSNumber(value: Int16.max))
XCTAssertEqual(Int32.max.cs_toUniqueIDNativeType(), NSNumber(value: Int32.max))
XCTAssertEqual(Int64.max.cs_toUniqueIDNativeType(), NSNumber(value: Int64.max))
XCTAssertEqual(MAXFLOAT.cs_toUniqueIDNativeType(), NSNumber(value: MAXFLOAT))
XCTAssertEqual(Double(MAXFLOAT).cs_toUniqueIDNativeType(), NSNumber(value: Double(MAXFLOAT)))
XCTAssertEqual(true.cs_toQueryableNativeType(), NSNumber(value: true))
XCTAssertEqual(Int16.max.cs_toQueryableNativeType(), NSNumber(value: Int16.max))
XCTAssertEqual(Int32.max.cs_toQueryableNativeType(), NSNumber(value: Int32.max))
XCTAssertEqual(Int64.max.cs_toQueryableNativeType(), NSNumber(value: Int64.max))
XCTAssertEqual(MAXFLOAT.cs_toQueryableNativeType(), NSNumber(value: MAXFLOAT))
XCTAssertEqual(Double(MAXFLOAT).cs_toQueryableNativeType(), NSNumber(value: Double(MAXFLOAT)))
}
@objc