Skip to content

Commit 920236f

Browse files
committed
Updated unit tests
1 parent a9a696a commit 920236f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// SortDescriptorTests.swift
3+
// CoreModel
4+
//
5+
// Created by Alsey Coleman Miller on 10/21/25.
6+
//
7+
8+
#if canImport(Darwin)
9+
import Foundation
10+
import Testing
11+
@testable import CoreModel
12+
@testable import CoreDataModel
13+
14+
@Suite struct SortDescriptorTests {
15+
16+
@Test func foundation() {
17+
18+
let events = [
19+
EventObject(
20+
id: 2,
21+
name: "Event 2",
22+
start: Date(timeIntervalSince1970: 60 * 60 * 2),
23+
speakers: [
24+
PersonObject(
25+
id: 2,
26+
name: "John Apple"
27+
)
28+
]),
29+
EventObject(
30+
id: 3,
31+
name: "Event 3",
32+
start: Date(timeIntervalSince1970: 60 * 60 * 4),
33+
speakers: [
34+
PersonObject(
35+
id: 1,
36+
name: "Alsey Coleman Miller"
37+
),
38+
PersonObject(
39+
id: 2,
40+
name: "John Apple"
41+
)
42+
]),
43+
EventObject(
44+
id: 1,
45+
name: "Event 1",
46+
start: Date(timeIntervalSince1970: 0),
47+
speakers: [
48+
PersonObject(
49+
id: 1,
50+
name: "Alsey Coleman Miller"
51+
)
52+
])
53+
]
54+
55+
let sort = SortDescriptor(\EventObject.id, order: .forward)
56+
57+
let sortedEvents = events.sorted(using: sort)
58+
59+
#expect(sortedEvents.map(\.id) == [1, 2, 3])
60+
}
61+
}
62+
#endif

0 commit comments

Comments
 (0)