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

Compare ColumnReference by intValue #139

Merged
merged 2 commits into from
Dec 9, 2020
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/CoreXLSX/Worksheet/ColumnReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extension ColumnReference: CustomStringConvertible {

extension ColumnReference: Comparable {
public static func <(lhs: ColumnReference, rhs: ColumnReference) -> Bool {
return lhs.value < rhs.value
return lhs.intValue < rhs.intValue
}

public static func ==(lhs: ColumnReference, rhs: ColumnReference) -> Bool {
Expand Down
10 changes: 10 additions & 0 deletions Tests/CoreXLSXTests/CellReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ final class CellReferenceTests: XCTestCase {
XCTAssertEqual((az ... bz).count, alphabetLength + 1)
}

func testColumnReferenceComparable() {
guard let ab = ColumnReference("AB"), let b = ColumnReference("B")
else {
XCTFail("failed to create simple column references")
return
}

XCTAssertGreaterThan(ab, b)
}

func testColumnReferenceIntInitializer() {
guard let a = ColumnReference("A"), let z = ColumnReference("z"),
let aa = ColumnReference("AA"), let az = ColumnReference("Az"),
Expand Down
1 change: 1 addition & 0 deletions Tests/CoreXLSXTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extension CellReferenceTests {
("testCellReference", testCellReference),
("testColumnReference", testColumnReference),
("testColumnReferenceAdvancedBy", testColumnReferenceAdvancedBy),
("testColumnReferenceComparable", testColumnReferenceComparable),
("testColumnReferenceDistance", testColumnReferenceDistance),
("testColumnReferenceIntInitializer", testColumnReferenceIntInitializer),
("testColumnReferenceIntInitializerPerformance", testColumnReferenceIntInitializerPerformance),
Expand Down