Skip to content

Commit 0ad1808

Browse files
authored
Merge pull request #126 from apelisse/perf/improve-equality
Implement equality for Values
2 parents 1ad9a28 + b45ef08 commit 0ad1808

File tree

2 files changed

+204
-64
lines changed

2 files changed

+204
-64
lines changed

value/less_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ func TestValueLess(t *testing.T) {
296296
t.Run(table[i].name, func(t *testing.T) {
297297
tt := table[i]
298298
if tt.eq {
299+
if !tt.a.Equals(tt.b) {
300+
t.Errorf("oops, a != b: %#v, %#v", tt.a, tt.b)
301+
}
299302
if tt.a.Less(tt.b) {
300303
t.Errorf("oops, a < b: %#v, %#v", tt.a, tt.b)
301304
}
@@ -307,6 +310,19 @@ func TestValueLess(t *testing.T) {
307310
if tt.b.Less(tt.a) {
308311
t.Errorf("oops, b < a: %#v, %#v", tt.b, tt.a)
309312
}
313+
314+
if tt.eq {
315+
if tt.a.Compare(tt.b) != 0 || tt.b.Compare(tt.b) != 0 {
316+
t.Errorf("oops, a != b: %#v, %#v", tt.a, tt.b)
317+
}
318+
} else {
319+
if !(tt.a.Compare(tt.b) < 0) {
320+
t.Errorf("oops, a is not less than b: %#v, %#v", tt.a, tt.b)
321+
}
322+
if !(tt.b.Compare(tt.a) > 0) {
323+
t.Errorf("oops, b is not more than a: %#v, %#v", tt.a, tt.b)
324+
}
325+
}
310326
})
311327
}
312328

0 commit comments

Comments
 (0)