PrimitiveListTests.swift 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2017 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. // swiftlint:disable type_name identifier_name cyclomatic_complexity
  19. import XCTest
  20. import RealmSwift
  21. protocol ObjectFactory {
  22. static func isManaged() -> Bool
  23. }
  24. final class ManagedObjectFactory: ObjectFactory {
  25. static func isManaged() -> Bool { return true }
  26. }
  27. final class UnmanagedObjectFactory: ObjectFactory {
  28. static func isManaged() -> Bool { return false }
  29. }
  30. protocol ValueFactory {
  31. associatedtype T: RealmCollectionValue
  32. associatedtype W: RealmCollectionValue = T
  33. static func array(_ obj: SwiftListObject) -> List<T>
  34. static func values() -> [T]
  35. }
  36. final class IntFactory: ValueFactory {
  37. static func array(_ obj: SwiftListObject) -> List<Int> {
  38. return obj.int
  39. }
  40. static func values() -> [Int] {
  41. return [1, 2, 3]
  42. }
  43. }
  44. final class Int8Factory: ValueFactory {
  45. static func array(_ obj: SwiftListObject) -> List<Int8> {
  46. return obj.int8
  47. }
  48. static func values() -> [Int8] {
  49. return [1, 2, 3]
  50. }
  51. }
  52. final class Int16Factory: ValueFactory {
  53. static func array(_ obj: SwiftListObject) -> List<Int16> {
  54. return obj.int16
  55. }
  56. static func values() -> [Int16] {
  57. return [1, 2, 3]
  58. }
  59. }
  60. final class Int32Factory: ValueFactory {
  61. static func array(_ obj: SwiftListObject) -> List<Int32> {
  62. return obj.int32
  63. }
  64. static func values() -> [Int32] {
  65. return [1, 2, 3]
  66. }
  67. }
  68. final class Int64Factory: ValueFactory {
  69. static func array(_ obj: SwiftListObject) -> List<Int64> {
  70. return obj.int64
  71. }
  72. static func values() -> [Int64] {
  73. return [1, 2, 3]
  74. }
  75. }
  76. final class FloatFactory: ValueFactory {
  77. static func array(_ obj: SwiftListObject) -> List<Float> {
  78. return obj.float
  79. }
  80. static func values() -> [Float] {
  81. return [1.1, 2.2, 3.3]
  82. }
  83. }
  84. final class DoubleFactory: ValueFactory {
  85. static func array(_ obj: SwiftListObject) -> List<Double> {
  86. return obj.double
  87. }
  88. static func values() -> [Double] {
  89. return [1.1, 2.2, 3.3]
  90. }
  91. }
  92. final class StringFactory: ValueFactory {
  93. static func array(_ obj: SwiftListObject) -> List<String> {
  94. return obj.string
  95. }
  96. static func values() -> [String] {
  97. return ["a", "b", "c"]
  98. }
  99. }
  100. final class DataFactory: ValueFactory {
  101. static func array(_ obj: SwiftListObject) -> List<Data> {
  102. return obj.data
  103. }
  104. static func values() -> [Data] {
  105. return ["a".data(using: .utf8)!, "b".data(using: .utf8)!, "c".data(using: .utf8)!]
  106. }
  107. }
  108. final class DateFactory: ValueFactory {
  109. static func array(_ obj: SwiftListObject) -> List<Date> {
  110. return obj.date
  111. }
  112. static func values() -> [Date] {
  113. return [Date(), Date().addingTimeInterval(10), Date().addingTimeInterval(20)]
  114. }
  115. }
  116. final class OptionalIntFactory: ValueFactory {
  117. typealias W = Int
  118. static func array(_ obj: SwiftListObject) -> List<Int?> {
  119. return obj.intOpt
  120. }
  121. static func values() -> [Int?] {
  122. return [nil, 1, 3]
  123. }
  124. }
  125. final class OptionalInt8Factory: ValueFactory {
  126. typealias W = Int8
  127. static func array(_ obj: SwiftListObject) -> List<Int8?> {
  128. return obj.int8Opt
  129. }
  130. static func values() -> [Int8?] {
  131. return [nil, 1, 3]
  132. }
  133. }
  134. final class OptionalInt16Factory: ValueFactory {
  135. typealias W = Int16
  136. static func array(_ obj: SwiftListObject) -> List<Int16?> {
  137. return obj.int16Opt
  138. }
  139. static func values() -> [Int16?] {
  140. return [nil, 1, 3]
  141. }
  142. }
  143. final class OptionalInt32Factory: ValueFactory {
  144. typealias W = Int32
  145. static func array(_ obj: SwiftListObject) -> List<Int32?> {
  146. return obj.int32Opt
  147. }
  148. static func values() -> [Int32?] {
  149. return [nil, 1, 3]
  150. }
  151. }
  152. final class OptionalInt64Factory: ValueFactory {
  153. typealias W = Int64
  154. static func array(_ obj: SwiftListObject) -> List<Int64?> {
  155. return obj.int64Opt
  156. }
  157. static func values() -> [Int64?] {
  158. return [nil, 1, 3]
  159. }
  160. }
  161. final class OptionalFloatFactory: ValueFactory {
  162. typealias W = Float
  163. static func array(_ obj: SwiftListObject) -> List<Float?> {
  164. return obj.floatOpt
  165. }
  166. static func values() -> [Float?] {
  167. return [nil, 1.1, 3.3]
  168. }
  169. }
  170. final class OptionalDoubleFactory: ValueFactory {
  171. typealias W = Double
  172. static func array(_ obj: SwiftListObject) -> List<Double?> {
  173. return obj.doubleOpt
  174. }
  175. static func values() -> [Double?] {
  176. return [nil, 1.1, 3.3]
  177. }
  178. }
  179. final class OptionalStringFactory: ValueFactory {
  180. typealias W = String
  181. static func array(_ obj: SwiftListObject) -> List<String?> {
  182. return obj.stringOpt
  183. }
  184. static func values() -> [String?] {
  185. return [nil, "a", "c"]
  186. }
  187. }
  188. final class OptionalDataFactory: ValueFactory {
  189. typealias W = Data
  190. static func array(_ obj: SwiftListObject) -> List<Data?> {
  191. return obj.dataOpt
  192. }
  193. static func values() -> [Data?] {
  194. return [nil, "a".data(using: .utf8), "c".data(using: .utf8)]
  195. }
  196. }
  197. final class OptionalDateFactory: ValueFactory {
  198. typealias W = Date
  199. static func array(_ obj: SwiftListObject) -> List<Date?> {
  200. return obj.dateOpt
  201. }
  202. static func values() -> [Date?] {
  203. return [nil, Date(), Date().addingTimeInterval(20)]
  204. }
  205. }
  206. class EquatableTestCase: TestCase {
  207. func assertEqualTo<T: Equatable>(_ expected: T, _ actual: T, fileName: StaticString = #file, lineNumber: UInt = #line) {
  208. XCTAssertEqual(expected, actual, file: fileName, line: lineNumber)
  209. }
  210. }
  211. class PrimitiveListTestsBase<O: ObjectFactory, V: ValueFactory>: EquatableTestCase {
  212. var realm: Realm?
  213. var obj: SwiftListObject!
  214. var array: List<V.T>!
  215. var values: [V.T]!
  216. #if swift(>=4)
  217. class func _defaultTestSuite() -> XCTestSuite {
  218. return defaultTestSuite
  219. }
  220. #else
  221. class func _defaultTestSuite() -> XCTestSuite {
  222. return defaultTestSuite()
  223. }
  224. #endif
  225. override func setUp() {
  226. obj = SwiftListObject()
  227. if O.isManaged() {
  228. let config = Realm.Configuration(inMemoryIdentifier: "test", objectTypes: [SwiftListObject.self])
  229. realm = try! Realm(configuration: config)
  230. realm!.beginWrite()
  231. realm!.add(obj)
  232. }
  233. array = V.array(obj)
  234. values = V.values()
  235. }
  236. override func tearDown() {
  237. realm?.cancelWrite()
  238. realm = nil
  239. array = nil
  240. obj = nil
  241. }
  242. }
  243. class PrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> {
  244. func testInvalidated() {
  245. XCTAssertFalse(array.isInvalidated)
  246. if let realm = obj.realm {
  247. realm.delete(obj)
  248. XCTAssertTrue(array.isInvalidated)
  249. }
  250. }
  251. func testIndexOf() {
  252. XCTAssertNil(array.index(of: values[0]))
  253. array.append(values[0])
  254. assertEqualTo(0, array.index(of: values[0]))
  255. array.append(values[1])
  256. assertEqualTo(0, array.index(of: values[0]))
  257. assertEqualTo(1, array.index(of: values[1]))
  258. }
  259. // FIXME: Not yet implemented
  260. func disabled_testIndexMatching() {
  261. XCTAssertNil(array.index(matching: "self = %@", values[0]))
  262. array.append(values[0])
  263. assertEqualTo(0, array.index(matching: "self = %@", values[0]))
  264. array.append(values[1])
  265. assertEqualTo(0, array.index(matching: "self = %@", values[0]))
  266. assertEqualTo(1, array.index(matching: "self = %@", values[1]))
  267. }
  268. func testSubscript() {
  269. array.append(objectsIn: values)
  270. for i in 0..<values.count {
  271. assertEqualTo(array[i], values[i])
  272. }
  273. assertThrows(array[values.count], reason: "Index 3 is out of bounds")
  274. assertThrows(array[-1], reason: "negative value")
  275. }
  276. func testFirst() {
  277. array.append(objectsIn: values)
  278. assertEqualTo(array.first, values.first)
  279. array.removeAll()
  280. XCTAssertNil(array.first)
  281. }
  282. func testLast() {
  283. array.append(objectsIn: values)
  284. assertEqualTo(array.last, values.last)
  285. array.removeAll()
  286. XCTAssertNil(array.last)
  287. }
  288. func testValueForKey() {
  289. assertEqualTo(array.value(forKey: "self").count, 0)
  290. array.append(objectsIn: values)
  291. assertEqualTo(values!, array.value(forKey: "self").map { dynamicBridgeCast(fromObjectiveC: $0) as V.T })
  292. assertThrows(array.value(forKey: "not self"), named: "NSUnknownKeyException")
  293. }
  294. func testSetValueForKey() {
  295. // does this even make any sense?
  296. }
  297. func testFilter() {
  298. // not implemented
  299. }
  300. func testInsert() {
  301. assertEqualTo(Int(0), array.count)
  302. array.insert(values[0], at: 0)
  303. assertEqualTo(Int(1), array.count)
  304. assertEqualTo(values[0], array[0])
  305. array.insert(values[1], at: 0)
  306. assertEqualTo(Int(2), array.count)
  307. assertEqualTo(values[1], array[0])
  308. assertEqualTo(values[0], array[1])
  309. array.insert(values[2], at: 2)
  310. assertEqualTo(Int(3), array.count)
  311. assertEqualTo(values[1], array[0])
  312. assertEqualTo(values[0], array[1])
  313. assertEqualTo(values[2], array[2])
  314. assertThrows(_ = array.insert(values[0], at: 4))
  315. assertThrows(_ = array.insert(values[0], at: -1))
  316. }
  317. func testRemove() {
  318. assertThrows(array.remove(at: 0))
  319. assertThrows(array.remove(at: -1))
  320. array.append(objectsIn: values)
  321. assertThrows(array.remove(at: -1))
  322. assertEqualTo(values[0], array[0])
  323. assertEqualTo(values[1], array[1])
  324. assertEqualTo(values[2], array[2])
  325. assertThrows(array[3])
  326. array.remove(at: 0)
  327. assertEqualTo(values[1], array[0])
  328. assertEqualTo(values[2], array[1])
  329. assertThrows(array[2])
  330. assertThrows(array.remove(at: 2))
  331. array.remove(at: 1)
  332. assertEqualTo(values[1], array[0])
  333. assertThrows(array[1])
  334. }
  335. func testRemoveLast() {
  336. assertThrows(array.removeLast())
  337. array.append(objectsIn: values)
  338. array.removeLast()
  339. assertEqualTo(array.count, 2)
  340. assertEqualTo(values[0], array[0])
  341. assertEqualTo(values[1], array[1])
  342. array.removeLast(2)
  343. assertEqualTo(array.count, 0)
  344. }
  345. func testRemoveAll() {
  346. array.removeAll()
  347. array.append(objectsIn: values)
  348. array.removeAll()
  349. assertEqualTo(array.count, 0)
  350. }
  351. func testReplace() {
  352. assertThrows(array.replace(index: 0, object: values[0]),
  353. reason: "Index 0 is out of bounds")
  354. array.append(objectsIn: values)
  355. array.replace(index: 1, object: values[0])
  356. assertEqualTo(array[0], values[0])
  357. assertEqualTo(array[1], values[0])
  358. assertEqualTo(array[2], values[2])
  359. assertThrows(array.replace(index: 3, object: values[0]),
  360. reason: "Index 3 is out of bounds")
  361. assertThrows(array.replace(index: -1, object: values[0]),
  362. reason: "Cannot pass a negative value")
  363. }
  364. func testReplaceRange() {
  365. assertSucceeds { array.replaceSubrange(0..<0, with: []) }
  366. #if false
  367. // FIXME: The exception thrown here runs afoul of Swift's exclusive access checking.
  368. assertThrows(array.replaceSubrange(0..<1, with: []),
  369. reason: "Index 0 is out of bounds")
  370. #endif
  371. array.replaceSubrange(0..<0, with: [values[0]])
  372. XCTAssertEqual(array.count, 1)
  373. assertEqualTo(array[0], values[0])
  374. array.replaceSubrange(0..<1, with: values)
  375. XCTAssertEqual(array.count, 3)
  376. array.replaceSubrange(1..<2, with: [])
  377. XCTAssertEqual(array.count, 2)
  378. assertEqualTo(array[0], values[0])
  379. assertEqualTo(array[1], values[2])
  380. }
  381. func testMove() {
  382. assertThrows(array.move(from: 1, to: 0), reason: "out of bounds")
  383. array.append(objectsIn: values)
  384. array.move(from: 2, to: 0)
  385. assertEqualTo(array[0], values[2])
  386. assertEqualTo(array[1], values[0])
  387. assertEqualTo(array[2], values[1])
  388. assertThrows(array.move(from: 3, to: 0), reason: "Index 3 is out of bounds")
  389. assertThrows(array.move(from: 0, to: 3), reason: "Index 3 is out of bounds")
  390. assertThrows(array.move(from: -1, to: 0), reason: "negative value")
  391. assertThrows(array.move(from: 0, to: -1), reason: "negative value")
  392. }
  393. func testSwap() {
  394. assertThrows(array.swapAt(0, 1), reason: "out of bounds")
  395. array.append(objectsIn: values)
  396. array.swapAt(0, 2)
  397. assertEqualTo(array[0], values[2])
  398. assertEqualTo(array[1], values[1])
  399. assertEqualTo(array[2], values[0])
  400. assertThrows(array.swapAt(3, 0), reason: "Index 3 is out of bounds")
  401. assertThrows(array.swapAt(0, 3), reason: "Index 3 is out of bounds")
  402. assertThrows(array.swapAt(-1, 0), reason: "negative value")
  403. assertThrows(array.swapAt(0, -1), reason: "negative value")
  404. }
  405. }
  406. class MinMaxPrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.T: MinMaxType {
  407. func testMin() {
  408. XCTAssertNil(array.min())
  409. array.append(objectsIn: values.reversed())
  410. assertEqualTo(array.min(), values.first)
  411. }
  412. func testMax() {
  413. XCTAssertNil(array.max())
  414. array.append(objectsIn: values.reversed())
  415. assertEqualTo(array.max(), values.last)
  416. }
  417. }
  418. class OptionalMinMaxPrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.W: MinMaxType {
  419. // V.T and V.W? are the same thing, but the type system doesn't know that
  420. // and the protocol constraint is on V.W
  421. var array2: List<V.W?> {
  422. return unsafeDowncast(array!, to: List<V.W?>.self)
  423. }
  424. func testMin() {
  425. XCTAssertNil(array2.min())
  426. array.append(objectsIn: values.reversed())
  427. let expected = values[1] as! V.W
  428. assertEqualTo(array2.min(), expected)
  429. }
  430. func testMax() {
  431. XCTAssertNil(array2.max())
  432. array.append(objectsIn: values.reversed())
  433. let expected = values[2] as! V.W
  434. assertEqualTo(array2.max(), expected)
  435. }
  436. }
  437. class AddablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.T: AddableType {
  438. func testSum() {
  439. assertEqualTo(array.sum(), V.T())
  440. array.append(objectsIn: values)
  441. // Expressing "can be added and converted to a floating point type" as
  442. // a protocol requirement is awful, so sidestep it all with obj-c
  443. let expected = ((values.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@sum.self")! as! NSNumber).doubleValue
  444. let actual: V.T = array.sum()
  445. XCTAssertEqual((dynamicBridgeCast(fromSwift: actual) as! NSNumber).doubleValue, expected, accuracy: 0.01)
  446. }
  447. func testAverage() {
  448. XCTAssertNil(array.average())
  449. array.append(objectsIn: values)
  450. let expected = ((values.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@avg.self")! as! NSNumber).doubleValue
  451. XCTAssertEqual(array.average()!, expected, accuracy: 0.01)
  452. }
  453. }
  454. class OptionalAddablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.W: AddableType {
  455. // V.T and V.W? are the same thing, but the type system doesn't know that
  456. // and the protocol constraint is on V.W
  457. var array2: List<V.W?> {
  458. return unsafeDowncast(array!, to: List<V.W?>.self)
  459. }
  460. func testSum() {
  461. assertEqualTo(array2.sum(), V.W())
  462. array.append(objectsIn: values)
  463. var nonNil = values!
  464. nonNil.remove(at: 0)
  465. // Expressing "can be added and converted to a floating point type" as
  466. // a protocol requirement is awful, so sidestep it all with obj-c
  467. let expected = ((nonNil.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@sum.self")! as! NSNumber).doubleValue
  468. let actual: V.W = array2.sum()
  469. XCTAssertEqual((dynamicBridgeCast(fromSwift: actual) as! NSNumber).doubleValue, expected, accuracy: 0.01)
  470. }
  471. func testAverage() {
  472. XCTAssertNil(array2.average())
  473. array.append(objectsIn: values)
  474. var nonNil = values!
  475. nonNil.remove(at: 0)
  476. let expected = ((nonNil.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@avg.self")! as! NSNumber).doubleValue
  477. XCTAssertEqual(array2.average()!, expected, accuracy: 0.01)
  478. }
  479. }
  480. class SortablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.T: Comparable {
  481. func testSorted() {
  482. var shuffled = values!
  483. shuffled.removeFirst()
  484. shuffled.append(values!.first!)
  485. array.append(objectsIn: shuffled)
  486. assertEqual(Array(array.sorted(ascending: true)), values)
  487. assertEqual(Array(array.sorted(ascending: false)), values.reversed())
  488. }
  489. }
  490. class OptionalSortablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.W: Comparable {
  491. func testSorted() {
  492. var shuffled = values!
  493. shuffled.removeFirst()
  494. shuffled.append(values!.first!)
  495. array.append(objectsIn: shuffled)
  496. let array2 = unsafeDowncast(array!, to: List<V.W?>.self)
  497. let values2 = unsafeBitCast(values!, to: Array<V.W?>.self)
  498. assertEqual(Array(array2.sorted(ascending: true)), values2)
  499. assertEqual(Array(array2.sorted(ascending: false)), values2.reversed())
  500. }
  501. }
  502. func addTests<OF: ObjectFactory>(_ suite: XCTestSuite, _ type: OF.Type) {
  503. _ = PrimitiveListTests<OF, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  504. _ = PrimitiveListTests<OF, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  505. _ = PrimitiveListTests<OF, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  506. _ = PrimitiveListTests<OF, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  507. _ = PrimitiveListTests<OF, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  508. _ = PrimitiveListTests<OF, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  509. _ = PrimitiveListTests<OF, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  510. _ = PrimitiveListTests<OF, StringFactory>._defaultTestSuite().tests.map(suite.addTest)
  511. _ = PrimitiveListTests<OF, DataFactory>._defaultTestSuite().tests.map(suite.addTest)
  512. _ = PrimitiveListTests<OF, DateFactory>._defaultTestSuite().tests.map(suite.addTest)
  513. _ = MinMaxPrimitiveListTests<OF, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  514. _ = MinMaxPrimitiveListTests<OF, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  515. _ = MinMaxPrimitiveListTests<OF, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  516. _ = MinMaxPrimitiveListTests<OF, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  517. _ = MinMaxPrimitiveListTests<OF, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  518. _ = MinMaxPrimitiveListTests<OF, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  519. _ = MinMaxPrimitiveListTests<OF, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  520. _ = MinMaxPrimitiveListTests<OF, DateFactory>._defaultTestSuite().tests.map(suite.addTest)
  521. _ = AddablePrimitiveListTests<OF, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  522. _ = AddablePrimitiveListTests<OF, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  523. _ = AddablePrimitiveListTests<OF, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  524. _ = AddablePrimitiveListTests<OF, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  525. _ = AddablePrimitiveListTests<OF, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  526. _ = AddablePrimitiveListTests<OF, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  527. _ = AddablePrimitiveListTests<OF, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  528. _ = PrimitiveListTests<OF, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  529. _ = PrimitiveListTests<OF, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  530. _ = PrimitiveListTests<OF, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  531. _ = PrimitiveListTests<OF, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  532. _ = PrimitiveListTests<OF, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  533. _ = PrimitiveListTests<OF, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  534. _ = PrimitiveListTests<OF, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  535. _ = PrimitiveListTests<OF, OptionalStringFactory>._defaultTestSuite().tests.map(suite.addTest)
  536. _ = PrimitiveListTests<OF, OptionalDataFactory>._defaultTestSuite().tests.map(suite.addTest)
  537. _ = PrimitiveListTests<OF, OptionalDateFactory>._defaultTestSuite().tests.map(suite.addTest)
  538. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  539. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  540. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  541. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  542. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  543. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  544. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  545. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalDateFactory>._defaultTestSuite().tests.map(suite.addTest)
  546. _ = OptionalAddablePrimitiveListTests<OF, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  547. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  548. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  549. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  550. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  551. _ = OptionalAddablePrimitiveListTests<OF, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  552. _ = OptionalAddablePrimitiveListTests<OF, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  553. }
  554. class UnmanagedPrimitiveListTests: TestCase {
  555. class func _defaultTestSuite() -> XCTestSuite {
  556. let suite = XCTestSuite(name: "Unmanaged Primitive Lists")
  557. addTests(suite, UnmanagedObjectFactory.self)
  558. return suite
  559. }
  560. #if swift(>=4)
  561. override class var defaultTestSuite: XCTestSuite {
  562. return _defaultTestSuite()
  563. }
  564. #else
  565. override class func defaultTestSuite() -> XCTestSuite {
  566. return _defaultTestSuite()
  567. }
  568. #endif
  569. }
  570. class ManagedPrimitiveListTests: TestCase {
  571. class func _defaultTestSuite() -> XCTestSuite {
  572. let suite = XCTestSuite(name: "Managed Primitive Lists")
  573. addTests(suite, ManagedObjectFactory.self)
  574. _ = SortablePrimitiveListTests<ManagedObjectFactory, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  575. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  576. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  577. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  578. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  579. _ = SortablePrimitiveListTests<ManagedObjectFactory, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  580. _ = SortablePrimitiveListTests<ManagedObjectFactory, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  581. _ = SortablePrimitiveListTests<ManagedObjectFactory, StringFactory>._defaultTestSuite().tests.map(suite.addTest)
  582. _ = SortablePrimitiveListTests<ManagedObjectFactory, DateFactory>._defaultTestSuite().tests.map(suite.addTest)
  583. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  584. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  585. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  586. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  587. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  588. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  589. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  590. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalStringFactory>._defaultTestSuite().tests.map(suite.addTest)
  591. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalDateFactory>._defaultTestSuite().tests.map(suite.addTest)
  592. return suite
  593. }
  594. #if swift(>=4)
  595. override class var defaultTestSuite: XCTestSuite {
  596. return _defaultTestSuite()
  597. }
  598. #else
  599. override class func defaultTestSuite() -> XCTestSuite {
  600. return _defaultTestSuite()
  601. }
  602. #endif
  603. }