2015-03-20 08:58:32 +00:00
|
|
|
// Copyright (C) 2015 The Protocol Authors.
|
|
|
|
|
|
|
|
package protocol
|
|
|
|
|
2016-07-04 10:40:29 +00:00
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
"testing"
|
|
|
|
)
|
2015-03-20 08:58:32 +00:00
|
|
|
|
|
|
|
func TestUpdate(t *testing.T) {
|
|
|
|
var v Vector
|
|
|
|
|
|
|
|
// Append
|
|
|
|
|
|
|
|
v = v.Update(42)
|
2018-12-18 11:36:38 +00:00
|
|
|
expected := Vector{Counters: []Counter{{ID: 42, Value: 1}}}
|
2015-03-20 08:58:32 +00:00
|
|
|
|
|
|
|
if v.Compare(expected) != Equal {
|
|
|
|
t.Errorf("Update error, %+v != %+v", v, expected)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert at front
|
|
|
|
|
|
|
|
v = v.Update(36)
|
2018-12-18 11:36:38 +00:00
|
|
|
expected = Vector{Counters: []Counter{{ID: 36, Value: 1}, {ID: 42, Value: 1}}}
|
2015-03-20 08:58:32 +00:00
|
|
|
|
|
|
|
if v.Compare(expected) != Equal {
|
|
|
|
t.Errorf("Update error, %+v != %+v", v, expected)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert in moddle
|
|
|
|
|
|
|
|
v = v.Update(37)
|
2018-12-18 11:36:38 +00:00
|
|
|
expected = Vector{Counters: []Counter{{ID: 36, Value: 1}, {ID: 37, Value: 1}, {ID: 42, Value: 1}}}
|
2015-03-20 08:58:32 +00:00
|
|
|
|
|
|
|
if v.Compare(expected) != Equal {
|
|
|
|
t.Errorf("Update error, %+v != %+v", v, expected)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update existing
|
|
|
|
|
|
|
|
v = v.Update(37)
|
2018-12-18 11:36:38 +00:00
|
|
|
expected = Vector{Counters: []Counter{{ID: 36, Value: 1}, {ID: 37, Value: 2}, {ID: 42, Value: 1}}}
|
2015-03-20 08:58:32 +00:00
|
|
|
|
|
|
|
if v.Compare(expected) != Equal {
|
|
|
|
t.Errorf("Update error, %+v != %+v", v, expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCopy(t *testing.T) {
|
2018-12-18 11:36:38 +00:00
|
|
|
v0 := Vector{Counters: []Counter{{ID: 42, Value: 1}}}
|
2015-03-20 08:58:32 +00:00
|
|
|
v1 := v0.Copy()
|
|
|
|
v1.Update(42)
|
|
|
|
if v0.Compare(v1) != Lesser {
|
|
|
|
t.Errorf("Copy error, %+v should be ancestor of %+v", v0, v1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMerge(t *testing.T) {
|
|
|
|
testcases := []struct {
|
|
|
|
a, b, m Vector
|
|
|
|
}{
|
|
|
|
// No-ops
|
|
|
|
{
|
|
|
|
Vector{},
|
|
|
|
Vector{},
|
|
|
|
Vector{},
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Appends
|
|
|
|
{
|
|
|
|
Vector{},
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Insert
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 23, Value: 2}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 23, Value: 2}, {ID: 42, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Update
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 1}, {ID: 42, Value: 2}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 2}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 2}, {ID: 42, Value: 2}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// All of the above
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 10, Value: 1}, {ID: 20, Value: 2}, {ID: 30, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 5, Value: 1}, {ID: 10, Value: 2}, {ID: 15, Value: 1}, {ID: 20, Value: 1}, {ID: 25, Value: 1}, {ID: 35, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 5, Value: 1}, {ID: 10, Value: 2}, {ID: 15, Value: 1}, {ID: 20, Value: 2}, {ID: 25, Value: 1}, {ID: 30, Value: 1}, {ID: 35, Value: 1}}},
|
2015-03-20 08:58:32 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range testcases {
|
|
|
|
if m := tc.a.Merge(tc.b); m.Compare(tc.m) != Equal {
|
|
|
|
t.Errorf("%d: %+v.Merge(%+v) == %+v (expected %+v)", i, tc.a, tc.b, m, tc.m)
|
|
|
|
}
|
|
|
|
}
|
2015-04-09 10:51:21 +00:00
|
|
|
}
|
2015-03-20 08:58:32 +00:00
|
|
|
|
2015-04-09 10:51:21 +00:00
|
|
|
func TestCounterValue(t *testing.T) {
|
2018-12-18 11:36:38 +00:00
|
|
|
v0 := Vector{Counters: []Counter{{ID: 42, Value: 1}, {ID: 64, Value: 5}}}
|
2015-04-09 10:51:21 +00:00
|
|
|
if v0.Counter(42) != 1 {
|
2015-09-22 18:34:24 +00:00
|
|
|
t.Errorf("Counter error, %d != %d", v0.Counter(42), 1)
|
2015-04-09 10:51:21 +00:00
|
|
|
}
|
|
|
|
if v0.Counter(64) != 5 {
|
2015-09-22 18:34:24 +00:00
|
|
|
t.Errorf("Counter error, %d != %d", v0.Counter(64), 5)
|
2015-04-09 10:51:21 +00:00
|
|
|
}
|
|
|
|
if v0.Counter(72) != 0 {
|
2015-09-22 18:34:24 +00:00
|
|
|
t.Errorf("Counter error, %d != %d", v0.Counter(72), 0)
|
2015-04-09 10:51:21 +00:00
|
|
|
}
|
2015-03-20 08:58:32 +00:00
|
|
|
}
|
2016-07-04 10:40:29 +00:00
|
|
|
|
|
|
|
func TestCompare(t *testing.T) {
|
|
|
|
testcases := []struct {
|
|
|
|
a, b Vector
|
|
|
|
r Ordering
|
|
|
|
}{
|
|
|
|
// Empty vectors are identical
|
|
|
|
{Vector{}, Vector{}, Equal},
|
2018-12-18 11:36:38 +00:00
|
|
|
{Vector{}, Vector{Counters: []Counter{{ID: 42, Value: 0}}}, Equal},
|
|
|
|
{Vector{Counters: []Counter{{ID: 42, Value: 0}}}, Vector{}, Equal},
|
2016-07-04 10:40:29 +00:00
|
|
|
|
|
|
|
// Zero is the implied value for a missing Counter
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 0}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 77, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Equal,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Equal vectors are equal
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 33}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 33}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Equal,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 33}, {ID: 77, Value: 24}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 33}, {ID: 77, Value: 24}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Equal,
|
|
|
|
},
|
|
|
|
|
|
|
|
// These a-vectors are all greater than the b-vector
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Vector{},
|
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 0, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 0, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: math.MaxUint64, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: math.MaxUint64, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 0, Value: math.MaxUint64}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 0, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: math.MaxUint64}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: math.MaxUint64, Value: math.MaxUint64}}},
|
|
|
|
Vector{Counters: []Counter{{ID: math.MaxUint64, Value: 0}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 0, Value: math.MaxUint64}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 0, Value: math.MaxUint64 - 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: math.MaxUint64}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: math.MaxUint64 - 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: math.MaxUint64, Value: math.MaxUint64}}},
|
|
|
|
Vector{Counters: []Counter{{ID: math.MaxUint64, Value: math.MaxUint64 - 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 2}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 2}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 2}, {ID: 77, Value: 3}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}, {ID: 77, Value: 3}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 2}, {ID: 77, Value: 3}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}, {ID: 77, Value: 3}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 23}, {ID: 42, Value: 2}, {ID: 77, Value: 4}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}, {ID: 77, Value: 3}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Greater,
|
|
|
|
},
|
|
|
|
|
|
|
|
// These a-vectors are all lesser than the b-vector
|
2018-12-18 11:36:38 +00:00
|
|
|
{Vector{}, Vector{Counters: []Counter{{ID: 42, Value: 1}}}, Lesser},
|
2016-07-04 10:40:29 +00:00
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 0}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Lesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 2}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Lesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 2}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Lesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 1}, {ID: 77, Value: 3}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 2}, {ID: 77, Value: 3}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Lesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}, {ID: 77, Value: 3}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 2}, {ID: 77, Value: 3}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Lesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}, {ID: 77, Value: 3}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 23}, {ID: 42, Value: 2}, {ID: 77, Value: 4}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
Lesser,
|
|
|
|
},
|
|
|
|
|
|
|
|
// These are all in conflict
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 2}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 43, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
ConcurrentGreater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 43, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 42, Value: 2}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
ConcurrentLesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 23}, {ID: 42, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 2}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
ConcurrentGreater,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 21}, {ID: 42, Value: 2}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 22}, {ID: 42, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
ConcurrentLesser,
|
|
|
|
},
|
|
|
|
{
|
2018-12-18 11:36:38 +00:00
|
|
|
Vector{Counters: []Counter{{ID: 22, Value: 21}, {ID: 42, Value: 2}, {ID: 43, Value: 1}}},
|
|
|
|
Vector{Counters: []Counter{{ID: 20, Value: 1}, {ID: 22, Value: 22}, {ID: 42, Value: 1}}},
|
2016-07-04 10:40:29 +00:00
|
|
|
ConcurrentLesser,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, tc := range testcases {
|
|
|
|
// Test real Compare
|
|
|
|
if r := tc.a.Compare(tc.b); r != tc.r {
|
|
|
|
t.Errorf("%d: %+v.Compare(%+v) == %v (expected %v)", i, tc.a, tc.b, r, tc.r)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test convenience functions
|
|
|
|
switch tc.r {
|
|
|
|
case Greater:
|
|
|
|
if tc.a.Equal(tc.b) {
|
|
|
|
t.Errorf("%+v == %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.Concurrent(tc.b) {
|
|
|
|
t.Errorf("%+v concurrent %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if !tc.a.GreaterEqual(tc.b) {
|
|
|
|
t.Errorf("%+v not >= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.LesserEqual(tc.b) {
|
|
|
|
t.Errorf("%+v <= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
case Lesser:
|
|
|
|
if tc.a.Concurrent(tc.b) {
|
|
|
|
t.Errorf("%+v concurrent %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.Equal(tc.b) {
|
|
|
|
t.Errorf("%+v == %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.GreaterEqual(tc.b) {
|
|
|
|
t.Errorf("%+v >= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if !tc.a.LesserEqual(tc.b) {
|
|
|
|
t.Errorf("%+v not <= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
case Equal:
|
|
|
|
if tc.a.Concurrent(tc.b) {
|
|
|
|
t.Errorf("%+v concurrent %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if !tc.a.Equal(tc.b) {
|
|
|
|
t.Errorf("%+v not == %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if !tc.a.GreaterEqual(tc.b) {
|
|
|
|
t.Errorf("%+v not <= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if !tc.a.LesserEqual(tc.b) {
|
|
|
|
t.Errorf("%+v not <= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
case ConcurrentLesser, ConcurrentGreater:
|
|
|
|
if !tc.a.Concurrent(tc.b) {
|
|
|
|
t.Errorf("%+v not concurrent %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.Equal(tc.b) {
|
|
|
|
t.Errorf("%+v == %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.GreaterEqual(tc.b) {
|
|
|
|
t.Errorf("%+v >= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
if tc.a.LesserEqual(tc.b) {
|
|
|
|
t.Errorf("%+v <= %+v", tc.a, tc.b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|