File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -99,4 +99,34 @@ describe CSUUID do
99
99
(uuid2 <=> uuid1).should eq 1
100
100
(uuid1 <=> uuid1).should eq 0
101
101
end
102
+
103
+ it " can compare CSUUIDs via <" do
104
+ uuid1 = CSUUID .new
105
+ uuid2 = CSUUID .new
106
+ (uuid1 < uuid2).should be_true
107
+ (uuid2 < uuid1).should be_false
108
+ end
109
+
110
+ it " can compare CSUUIDs via >" do
111
+ uuid1 = CSUUID .new
112
+ uuid2 = CSUUID .new
113
+ (uuid1 > uuid2).should be_false
114
+ (uuid2 > uuid1).should be_true
115
+ end
116
+
117
+ it " can compare CSUUIDs via <=" do
118
+ uuid1 = CSUUID .new
119
+ uuid2 = CSUUID .new
120
+ (uuid1 <= uuid2).should be_true
121
+ (uuid2 <= uuid1).should be_false
122
+ (uuid1 <= uuid1).should be_true
123
+ end
124
+
125
+ it " can compare CSUUIDs via >=" do
126
+ uuid1 = CSUUID .new
127
+ uuid2 = CSUUID .new
128
+ (uuid1 >= uuid2).should be_false
129
+ (uuid2 >= uuid1).should be_true
130
+ (uuid1 >= uuid1).should be_true
131
+ end
102
132
end
Original file line number Diff line number Diff line change @@ -180,4 +180,24 @@ struct CSUUID
180
180
181
181
to_s <=> val.to_s
182
182
end
183
+
184
+ # Returns `true` if `self` is less than *other*.
185
+ def < (other : CSUUID ) : Bool
186
+ (self <=> other) == -1
187
+ end
188
+
189
+ # Returns `true` if `self` is greater than *other*.
190
+ def > (other : CSUUID ) : Bool
191
+ (self <=> other) == 1
192
+ end
193
+
194
+ # Returns `true` if `self` is less than or equal to *other*.
195
+ def <= (other : CSUUID ) : Bool
196
+ self == other || self < other
197
+ end
198
+
199
+ # Returns `true` if `self` is greater than or equal to *other*.
200
+ def >= (other : CSUUID ) : Bool
201
+ self == other || self > other
202
+ end
183
203
end
You can’t perform that action at this time.
0 commit comments