2014-06-01 22:50:14 +02:00
|
|
|
// Copyright (C) 2014 Jakob Borg and other contributors. All rights reserved.
|
|
|
|
// Use of this source code is governed by an MIT-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-28 14:36:57 +01:00
|
|
|
package cid
|
|
|
|
|
2014-06-30 01:42:03 +02:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/calmh/syncthing/protocol"
|
|
|
|
)
|
2014-03-28 14:36:57 +01:00
|
|
|
|
|
|
|
func TestGet(t *testing.T) {
|
|
|
|
m := NewMap()
|
|
|
|
|
2014-06-30 01:42:03 +02:00
|
|
|
fooID := protocol.NewNodeID([]byte("foo"))
|
|
|
|
barID := protocol.NewNodeID([]byte("bar"))
|
|
|
|
|
|
|
|
if i := m.Get(fooID); i != 1 {
|
2014-03-28 14:36:57 +01:00
|
|
|
t.Errorf("Unexpected id %d != 1", i)
|
|
|
|
}
|
2014-06-30 01:42:03 +02:00
|
|
|
if i := m.Get(barID); i != 2 {
|
2014-03-28 14:36:57 +01:00
|
|
|
t.Errorf("Unexpected id %d != 2", i)
|
|
|
|
}
|
2014-06-30 01:42:03 +02:00
|
|
|
if i := m.Get(fooID); i != 1 {
|
2014-03-28 14:36:57 +01:00
|
|
|
t.Errorf("Unexpected id %d != 1", i)
|
|
|
|
}
|
2014-06-30 01:42:03 +02:00
|
|
|
if i := m.Get(barID); i != 2 {
|
2014-03-28 14:36:57 +01:00
|
|
|
t.Errorf("Unexpected id %d != 2", i)
|
|
|
|
}
|
|
|
|
|
|
|
|
if LocalID != 0 {
|
|
|
|
t.Error("LocalID should be 0")
|
|
|
|
}
|
2014-06-30 01:42:03 +02:00
|
|
|
if i := m.Get(LocalNodeID); i != LocalID {
|
|
|
|
t.Errorf("Unexpected id %d != %d", i, LocalID)
|
2014-03-28 14:36:57 +01:00
|
|
|
}
|
|
|
|
}
|