Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions foundationTests/ArrayCollectionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -736,15 +736,25 @@ class ArrayCollectionTest: XCTestCase {

let result = array.sorted(using: .keyPath(\.name), .keyPath(\.surname), .keyPath(\.age))
XCTAssertEqual([a,c,d,b], result)


}

/*func test_sum(){
let collection = [1, 2, 3, 4, 5]
func test_can_sort_array_with_multiple_keypahts_and_custom_order(){
struct TestStruct : Equatable {
let name:String
let surname:String
let age:Int
}

XCTAssertEqual(15, collection.sum())
}*/
let a = TestStruct(name: "ABC", surname: "DEF", age: 10)
let b = TestStruct(name: "DEF", surname: "GHI", age: 22)
let c = TestStruct(name: "ABC", surname: "GHI", age: 10)
let d = TestStruct(name: "DEF", surname: "GHI", age: 10)

let array:[TestStruct] = [a,b,c,d]

let result = array.sorted(using: .keyPath(\.name, order: .descending), .keyPath(\.surname, order: .ascending), .keyPath(\.age, order: .descending))
XCTAssertEqual([b,d,a,c], result)
}

func test_all_passes(){

Expand All @@ -753,7 +763,6 @@ class ArrayCollectionTest: XCTestCase {

let result2 = [10, 11, 12, 13].allPass { $0 > 10}
XCTAssertFalse(result2)

}

func test_all_fail(){
Expand Down