PrimitiveListTests.swift 26 KB

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