PrimitiveListTests.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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. struct ManagedObjectFactory: ObjectFactory {
  25. static func isManaged() -> Bool { return true }
  26. }
  27. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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. struct 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 PrimitiveListTestsBase<O: ObjectFactory, V: ValueFactory>: TestCase {
  207. var realm: Realm?
  208. var obj: SwiftListObject!
  209. var array: List<V.T>!
  210. var values: [V.T]!
  211. class func _defaultTestSuite() -> XCTestSuite {
  212. return defaultTestSuite
  213. }
  214. override func setUp() {
  215. obj = SwiftListObject()
  216. if O.isManaged() {
  217. let config = Realm.Configuration(inMemoryIdentifier: "test", objectTypes: [SwiftListObject.self])
  218. realm = try! Realm(configuration: config)
  219. realm!.beginWrite()
  220. realm!.add(obj)
  221. }
  222. array = V.array(obj)
  223. values = V.values()
  224. }
  225. override func tearDown() {
  226. realm?.cancelWrite()
  227. realm = nil
  228. array = nil
  229. obj = nil
  230. }
  231. }
  232. class PrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> {
  233. func testInvalidated() {
  234. XCTAssertFalse(array.isInvalidated)
  235. if let realm = obj.realm {
  236. realm.delete(obj)
  237. XCTAssertTrue(array.isInvalidated)
  238. }
  239. }
  240. func testIndexOf() {
  241. XCTAssertNil(array.index(of: values[0]))
  242. array.append(values[0])
  243. XCTAssertEqual(0, array.index(of: values[0]))
  244. array.append(values[1])
  245. XCTAssertEqual(0, array.index(of: values[0]))
  246. XCTAssertEqual(1, array.index(of: values[1]))
  247. }
  248. // FIXME: Not yet implemented
  249. func disabled_testIndexMatching() {
  250. XCTAssertNil(array.index(matching: "self = %@", values[0]))
  251. array.append(values[0])
  252. XCTAssertEqual(0, array.index(matching: "self = %@", values[0]))
  253. array.append(values[1])
  254. XCTAssertEqual(0, array.index(matching: "self = %@", values[0]))
  255. XCTAssertEqual(1, array.index(matching: "self = %@", values[1]))
  256. }
  257. func testSubscript() {
  258. array.append(objectsIn: values)
  259. for i in 0..<values.count {
  260. XCTAssertEqual(array[i], values[i])
  261. }
  262. assertThrows(array[values.count], reason: "Index 3 is out of bounds")
  263. assertThrows(array[-1], reason: "negative value")
  264. }
  265. func testFirst() {
  266. array.append(objectsIn: values)
  267. XCTAssertEqual(array.first, values.first)
  268. array.removeAll()
  269. XCTAssertNil(array.first)
  270. }
  271. func testLast() {
  272. array.append(objectsIn: values)
  273. XCTAssertEqual(array.last, values.last)
  274. array.removeAll()
  275. XCTAssertNil(array.last)
  276. }
  277. func testValueForKey() {
  278. XCTAssertEqual(array.value(forKey: "self").count, 0)
  279. array.append(objectsIn: values)
  280. XCTAssertEqual(values!, array.value(forKey: "self").map { dynamicBridgeCast(fromObjectiveC: $0) as V.T })
  281. assertThrows(array.value(forKey: "not self"), named: "NSUnknownKeyException")
  282. }
  283. func testSetValueForKey() {
  284. // does this even make any sense?
  285. }
  286. func testFilter() {
  287. // not implemented
  288. }
  289. func testInsert() {
  290. XCTAssertEqual(Int(0), array.count)
  291. array.insert(values[0], at: 0)
  292. XCTAssertEqual(Int(1), array.count)
  293. XCTAssertEqual(values[0], array[0])
  294. array.insert(values[1], at: 0)
  295. XCTAssertEqual(Int(2), array.count)
  296. XCTAssertEqual(values[1], array[0])
  297. XCTAssertEqual(values[0], array[1])
  298. array.insert(values[2], at: 2)
  299. XCTAssertEqual(Int(3), array.count)
  300. XCTAssertEqual(values[1], array[0])
  301. XCTAssertEqual(values[0], array[1])
  302. XCTAssertEqual(values[2], array[2])
  303. assertThrows(_ = array.insert(values[0], at: 4))
  304. assertThrows(_ = array.insert(values[0], at: -1))
  305. }
  306. func testRemove() {
  307. assertThrows(array.remove(at: 0))
  308. assertThrows(array.remove(at: -1))
  309. array.append(objectsIn: values)
  310. assertThrows(array.remove(at: -1))
  311. XCTAssertEqual(values[0], array[0])
  312. XCTAssertEqual(values[1], array[1])
  313. XCTAssertEqual(values[2], array[2])
  314. assertThrows(array[3])
  315. array.remove(at: 0)
  316. XCTAssertEqual(values[1], array[0])
  317. XCTAssertEqual(values[2], array[1])
  318. assertThrows(array[2])
  319. assertThrows(array.remove(at: 2))
  320. array.remove(at: 1)
  321. XCTAssertEqual(values[1], array[0])
  322. assertThrows(array[1])
  323. }
  324. func testRemoveLast() {
  325. assertThrows(array.removeLast())
  326. array.append(objectsIn: values)
  327. array.removeLast()
  328. XCTAssertEqual(array.count, 2)
  329. XCTAssertEqual(values[0], array[0])
  330. XCTAssertEqual(values[1], array[1])
  331. array.removeLast(2)
  332. XCTAssertEqual(array.count, 0)
  333. }
  334. func testRemoveAll() {
  335. array.removeAll()
  336. array.append(objectsIn: values)
  337. array.removeAll()
  338. XCTAssertEqual(array.count, 0)
  339. }
  340. func testReplace() {
  341. assertThrows(array.replace(index: 0, object: values[0]),
  342. reason: "Index 0 is out of bounds")
  343. array.append(objectsIn: values)
  344. array.replace(index: 1, object: values[0])
  345. XCTAssertEqual(array[0], values[0])
  346. XCTAssertEqual(array[1], values[0])
  347. XCTAssertEqual(array[2], values[2])
  348. assertThrows(array.replace(index: 3, object: values[0]),
  349. reason: "Index 3 is out of bounds")
  350. assertThrows(array.replace(index: -1, object: values[0]),
  351. reason: "Cannot pass a negative value")
  352. }
  353. func testReplaceRange() {
  354. assertSucceeds { array.replaceSubrange(0..<0, with: []) }
  355. #if false
  356. // FIXME: The exception thrown here runs afoul of Swift's exclusive access checking.
  357. assertThrows(array.replaceSubrange(0..<1, with: []),
  358. reason: "Index 0 is out of bounds")
  359. #endif
  360. array.replaceSubrange(0..<0, with: [values[0]])
  361. XCTAssertEqual(array.count, 1)
  362. XCTAssertEqual(array[0], values[0])
  363. array.replaceSubrange(0..<1, with: values)
  364. XCTAssertEqual(array.count, 3)
  365. array.replaceSubrange(1..<2, with: [])
  366. XCTAssertEqual(array.count, 2)
  367. XCTAssertEqual(array[0], values[0])
  368. XCTAssertEqual(array[1], values[2])
  369. }
  370. func testMove() {
  371. assertThrows(array.move(from: 1, to: 0), reason: "out of bounds")
  372. array.append(objectsIn: values)
  373. array.move(from: 2, to: 0)
  374. XCTAssertEqual(array[0], values[2])
  375. XCTAssertEqual(array[1], values[0])
  376. XCTAssertEqual(array[2], values[1])
  377. assertThrows(array.move(from: 3, to: 0), reason: "Index 3 is out of bounds")
  378. assertThrows(array.move(from: 0, to: 3), reason: "Index 3 is out of bounds")
  379. assertThrows(array.move(from: -1, to: 0), reason: "negative value")
  380. assertThrows(array.move(from: 0, to: -1), reason: "negative value")
  381. }
  382. func testSwap() {
  383. assertThrows(array.swapAt(0, 1), reason: "out of bounds")
  384. array.append(objectsIn: values)
  385. array.swapAt(0, 2)
  386. XCTAssertEqual(array[0], values[2])
  387. XCTAssertEqual(array[1], values[1])
  388. XCTAssertEqual(array[2], values[0])
  389. assertThrows(array.swapAt(3, 0), reason: "Index 3 is out of bounds")
  390. assertThrows(array.swapAt(0, 3), reason: "Index 3 is out of bounds")
  391. assertThrows(array.swapAt(-1, 0), reason: "negative value")
  392. assertThrows(array.swapAt(0, -1), reason: "negative value")
  393. }
  394. }
  395. class MinMaxPrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.T: MinMaxType {
  396. func testMin() {
  397. XCTAssertNil(array.min())
  398. array.append(objectsIn: values.reversed())
  399. XCTAssertEqual(array.min(), values.first)
  400. }
  401. func testMax() {
  402. XCTAssertNil(array.max())
  403. array.append(objectsIn: values.reversed())
  404. XCTAssertEqual(array.max(), values.last)
  405. }
  406. }
  407. class OptionalMinMaxPrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.W: MinMaxType {
  408. // V.T and V.W? are the same thing, but the type system doesn't know that
  409. // and the protocol constraint is on V.W
  410. var array2: List<V.W?> {
  411. return unsafeDowncast(array!, to: List<V.W?>.self)
  412. }
  413. func testMin() {
  414. XCTAssertNil(array2.min())
  415. array.append(objectsIn: values.reversed())
  416. let expected = values[1] as! V.W
  417. XCTAssertEqual(array2.min(), expected)
  418. }
  419. func testMax() {
  420. XCTAssertNil(array2.max())
  421. array.append(objectsIn: values.reversed())
  422. let expected = values[2] as! V.W
  423. XCTAssertEqual(array2.max(), expected)
  424. }
  425. }
  426. class AddablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.T: AddableType {
  427. func testSum() {
  428. XCTAssertEqual(array.sum(), V.T())
  429. array.append(objectsIn: values)
  430. // Expressing "can be added and converted to a floating point type" as
  431. // a protocol requirement is awful, so sidestep it all with obj-c
  432. let expected = ((values.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@sum.self")! as! NSNumber).doubleValue
  433. let actual: V.T = array.sum()
  434. XCTAssertEqual((dynamicBridgeCast(fromSwift: actual) as! NSNumber).doubleValue, expected, accuracy: 0.01)
  435. }
  436. func testAverage() {
  437. XCTAssertNil(array.average())
  438. array.append(objectsIn: values)
  439. let expected = ((values.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@avg.self")! as! NSNumber).doubleValue
  440. XCTAssertEqual(array.average()!, expected, accuracy: 0.01)
  441. }
  442. }
  443. class OptionalAddablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.W: AddableType {
  444. // V.T and V.W? are the same thing, but the type system doesn't know that
  445. // and the protocol constraint is on V.W
  446. var array2: List<V.W?> {
  447. return unsafeDowncast(array!, to: List<V.W?>.self)
  448. }
  449. func testSum() {
  450. XCTAssertEqual(array2.sum(), V.W())
  451. array.append(objectsIn: values)
  452. var nonNil = values!
  453. nonNil.remove(at: 0)
  454. // Expressing "can be added and converted to a floating point type" as
  455. // a protocol requirement is awful, so sidestep it all with obj-c
  456. let expected = ((nonNil.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@sum.self")! as! NSNumber).doubleValue
  457. let actual: V.W = array2.sum()
  458. XCTAssertEqual((dynamicBridgeCast(fromSwift: actual) as! NSNumber).doubleValue, expected, accuracy: 0.01)
  459. }
  460. func testAverage() {
  461. XCTAssertNil(array2.average())
  462. array.append(objectsIn: values)
  463. var nonNil = values!
  464. nonNil.remove(at: 0)
  465. let expected = ((nonNil.map(dynamicBridgeCast) as NSArray).value(forKeyPath: "@avg.self")! as! NSNumber).doubleValue
  466. XCTAssertEqual(array2.average()!, expected, accuracy: 0.01)
  467. }
  468. }
  469. class SortablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.T: Comparable {
  470. func testSorted() {
  471. var shuffled = values!
  472. shuffled.removeFirst()
  473. shuffled.append(values!.first!)
  474. array.append(objectsIn: shuffled)
  475. assertEqual(Array(array.sorted(ascending: true)), values)
  476. assertEqual(Array(array.sorted(ascending: false)), values.reversed())
  477. }
  478. }
  479. class OptionalSortablePrimitiveListTests<O: ObjectFactory, V: ValueFactory>: PrimitiveListTestsBase<O, V> where V.W: Comparable {
  480. func testSorted() {
  481. var shuffled = values!
  482. shuffled.removeFirst()
  483. shuffled.append(values!.first!)
  484. array.append(objectsIn: shuffled)
  485. let array2 = unsafeDowncast(array!, to: List<V.W?>.self)
  486. let values2 = unsafeBitCast(values!, to: Array<V.W?>.self)
  487. assertEqual(Array(array2.sorted(ascending: true)), values2)
  488. assertEqual(Array(array2.sorted(ascending: false)), values2.reversed())
  489. }
  490. }
  491. func addTests<OF: ObjectFactory>(_ suite: XCTestSuite, _ type: OF.Type) {
  492. _ = PrimitiveListTests<OF, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  493. _ = PrimitiveListTests<OF, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  494. _ = PrimitiveListTests<OF, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  495. _ = PrimitiveListTests<OF, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  496. _ = PrimitiveListTests<OF, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  497. _ = PrimitiveListTests<OF, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  498. _ = PrimitiveListTests<OF, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  499. _ = PrimitiveListTests<OF, StringFactory>._defaultTestSuite().tests.map(suite.addTest)
  500. _ = PrimitiveListTests<OF, DataFactory>._defaultTestSuite().tests.map(suite.addTest)
  501. _ = PrimitiveListTests<OF, DateFactory>._defaultTestSuite().tests.map(suite.addTest)
  502. _ = MinMaxPrimitiveListTests<OF, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  503. _ = MinMaxPrimitiveListTests<OF, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  504. _ = MinMaxPrimitiveListTests<OF, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  505. _ = MinMaxPrimitiveListTests<OF, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  506. _ = MinMaxPrimitiveListTests<OF, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  507. _ = MinMaxPrimitiveListTests<OF, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  508. _ = MinMaxPrimitiveListTests<OF, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  509. _ = MinMaxPrimitiveListTests<OF, DateFactory>._defaultTestSuite().tests.map(suite.addTest)
  510. _ = AddablePrimitiveListTests<OF, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  511. _ = AddablePrimitiveListTests<OF, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  512. _ = AddablePrimitiveListTests<OF, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  513. _ = AddablePrimitiveListTests<OF, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  514. _ = AddablePrimitiveListTests<OF, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  515. _ = AddablePrimitiveListTests<OF, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  516. _ = AddablePrimitiveListTests<OF, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  517. _ = PrimitiveListTests<OF, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  518. _ = PrimitiveListTests<OF, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  519. _ = PrimitiveListTests<OF, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  520. _ = PrimitiveListTests<OF, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  521. _ = PrimitiveListTests<OF, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  522. _ = PrimitiveListTests<OF, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  523. _ = PrimitiveListTests<OF, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  524. _ = PrimitiveListTests<OF, OptionalStringFactory>._defaultTestSuite().tests.map(suite.addTest)
  525. _ = PrimitiveListTests<OF, OptionalDataFactory>._defaultTestSuite().tests.map(suite.addTest)
  526. _ = PrimitiveListTests<OF, OptionalDateFactory>._defaultTestSuite().tests.map(suite.addTest)
  527. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  528. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  529. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  530. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  531. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  532. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  533. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  534. _ = OptionalMinMaxPrimitiveListTests<OF, OptionalDateFactory>._defaultTestSuite().tests.map(suite.addTest)
  535. _ = OptionalAddablePrimitiveListTests<OF, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  536. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  537. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  538. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  539. _ = OptionalAddablePrimitiveListTests<OF, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  540. _ = OptionalAddablePrimitiveListTests<OF, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  541. _ = OptionalAddablePrimitiveListTests<OF, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  542. }
  543. class UnmanagedPrimitiveListTests: TestCase {
  544. class func _defaultTestSuite() -> XCTestSuite {
  545. let suite = XCTestSuite(name: "Unmanaged Primitive Lists")
  546. addTests(suite, UnmanagedObjectFactory.self)
  547. return suite
  548. }
  549. override class var defaultTestSuite: XCTestSuite {
  550. return _defaultTestSuite()
  551. }
  552. }
  553. class ManagedPrimitiveListTests: TestCase {
  554. class func _defaultTestSuite() -> XCTestSuite {
  555. let suite = XCTestSuite(name: "Managed Primitive Lists")
  556. addTests(suite, ManagedObjectFactory.self)
  557. _ = SortablePrimitiveListTests<ManagedObjectFactory, IntFactory>._defaultTestSuite().tests.map(suite.addTest)
  558. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int8Factory>._defaultTestSuite().tests.map(suite.addTest)
  559. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int16Factory>._defaultTestSuite().tests.map(suite.addTest)
  560. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int32Factory>._defaultTestSuite().tests.map(suite.addTest)
  561. _ = SortablePrimitiveListTests<ManagedObjectFactory, Int64Factory>._defaultTestSuite().tests.map(suite.addTest)
  562. _ = SortablePrimitiveListTests<ManagedObjectFactory, FloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  563. _ = SortablePrimitiveListTests<ManagedObjectFactory, DoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  564. _ = SortablePrimitiveListTests<ManagedObjectFactory, StringFactory>._defaultTestSuite().tests.map(suite.addTest)
  565. _ = SortablePrimitiveListTests<ManagedObjectFactory, DateFactory>._defaultTestSuite().tests.map(suite.addTest)
  566. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalIntFactory>._defaultTestSuite().tests.map(suite.addTest)
  567. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt8Factory>._defaultTestSuite().tests.map(suite.addTest)
  568. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt16Factory>._defaultTestSuite().tests.map(suite.addTest)
  569. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt32Factory>._defaultTestSuite().tests.map(suite.addTest)
  570. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalInt64Factory>._defaultTestSuite().tests.map(suite.addTest)
  571. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalFloatFactory>._defaultTestSuite().tests.map(suite.addTest)
  572. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalDoubleFactory>._defaultTestSuite().tests.map(suite.addTest)
  573. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalStringFactory>._defaultTestSuite().tests.map(suite.addTest)
  574. _ = OptionalSortablePrimitiveListTests<ManagedObjectFactory, OptionalDateFactory>._defaultTestSuite().tests.map(suite.addTest)
  575. return suite
  576. }
  577. override class var defaultTestSuite: XCTestSuite {
  578. return _defaultTestSuite()
  579. }
  580. }