|
|
|
@ -12,7 +12,6 @@ type testElem struct {
|
|
|
|
|
Name string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lastID uniqueID.ID
|
|
|
|
|
|
|
|
|
|
func NewSampleElem(IDSpace *uniqueID.IDSpace, name string) *testElem {
|
|
|
|
@ -27,7 +26,7 @@ func (te *testElem) ID() uniqueID.ID {
|
|
|
|
|
return te.id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSet(t *testing.T) {
|
|
|
|
|
func TestNearest(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
testIDSpace := &uniqueID.IDSpace{}
|
|
|
|
|
set := Set{}
|
|
|
|
@ -50,7 +49,32 @@ func TestSet(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
tools.Test(set.Contains(lastID), "set did not contain added element", t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.Log(set.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSetValue(t *testing.T) {
|
|
|
|
|
testIDSpace := &uniqueID.IDSpace{}
|
|
|
|
|
set := Set{}
|
|
|
|
|
|
|
|
|
|
a := NewSampleElem(testIDSpace, "a")
|
|
|
|
|
b := NewSampleElem(testIDSpace, "b")
|
|
|
|
|
c := NewSampleElem(testIDSpace, "c")
|
|
|
|
|
d := NewSampleElem(testIDSpace, "d")
|
|
|
|
|
e := NewSampleElem(testIDSpace, "e")
|
|
|
|
|
|
|
|
|
|
err := set.Insert(a, 1); if err != nil {tools.WrapErr(err, "could not insert test element", t)}
|
|
|
|
|
err = set.Insert(b, 2); if err != nil {tools.WrapErr(err, "could not insert test element", t)}
|
|
|
|
|
err = set.Insert(c, 3); if err != nil {tools.WrapErr(err, "could not insert test element", t)}
|
|
|
|
|
err = set.Insert(d, 5); if err != nil {tools.WrapErr(err, "could not insert test element", t)}
|
|
|
|
|
err = set.Insert(e, 4); if err != nil {tools.WrapErr(err, "could not insert test element", t)}
|
|
|
|
|
|
|
|
|
|
set.SetValue(a.ID(), 3.5)
|
|
|
|
|
set.SetValue(e.ID(), -2)
|
|
|
|
|
|
|
|
|
|
tools.Test(set.Elems()[0] == e, "did not correctly change position when set new value", t)
|
|
|
|
|
tools.Test(set.Elems()[1] == b, "did not correctly change position when set new value", t)
|
|
|
|
|
tools.Test(set.Elems()[2] == c, "did not correctly change position when set new value", t)
|
|
|
|
|
tools.Test(set.Elems()[3] == a, "did not correctly change position when set new value", t)
|
|
|
|
|
tools.Test(set.Elems()[4] == d, "did not correctly change position when set new value", t)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|