File tree 2 files changed +14
-0
lines changed
Tests/DataStructuresTests 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ extension NewType {
17
17
}
18
18
}
19
19
20
+ extension NewType where Value: Comparable {
21
+ public static func < ( lhs: Self , rhs: Self ) -> Bool {
22
+ return lhs. value < rhs. value
23
+ }
24
+ }
25
+
20
26
extension NewType where Value: ExpressibleByIntegerLiteral {
21
27
public init ( integerLiteral value: Value . IntegerLiteralType ) {
22
28
self . init ( value: Value ( integerLiteral: value) )
Original file line number Diff line number Diff line change @@ -10,6 +10,14 @@ import DataStructures
10
10
11
11
class NewTypeTests : XCTestCase {
12
12
13
+ func testComparable( ) {
14
+ struct C : NewType , Comparable { let value : Int }
15
+ let a = C ( 1 )
16
+ let c = C ( 2 )
17
+ XCTAssert ( a < c)
18
+ XCTAssert ( c > a)
19
+ }
20
+
13
21
func testExpressibleByIntegerLiteral( ) {
14
22
struct I : NewType , ExpressibleByIntegerLiteral { let value : Int }
15
23
let _: I = 42
You can’t perform that action at this time.
0 commit comments