Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Index Ordering #203

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Sources/CodableDatastore/Indexes/Indexable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extension UInt64: DiscreteIndexable, RangedIndexable {}
extension Optional: Comparable where Wrapped: Comparable {
public static func < (lhs: Self, rhs: Self) -> Bool {
if let lhs, let rhs { return lhs < rhs }
return lhs == nil
return lhs == nil && rhs != nil
}
}
extension Optional: DiscreteIndexable where Wrapped: DiscreteIndexable {}
Expand Down
19 changes: 19 additions & 0 deletions Tests/CodableDatastoreTests/OptionalTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// OptionalTests.swift
// CodableDatastore
//
// Created by Dimitri Bouniol on 2024-04-20.
// Copyright © 2023-24 Mochi Development, Inc. All rights reserved.
//

import XCTest
@testable import CodableDatastore

final class OptionalTests: XCTestCase {
func testComparable() throws {
XCTAssertTrue(Int?.some(5) < Int?.some(10))
XCTAssertTrue(Int?.none < Int?.some(10))
XCTAssertFalse(Int?.some(5) < Int?.none)
XCTAssertFalse(Int?.none < Int?.none)
}
}
Loading