2019-04-20 10:39:06 +00:00
|
|
|
package needle
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestNewVolumeId(t *testing.T) {
|
2019-04-30 03:22:19 +00:00
|
|
|
if _, err := NewVolumeId("1"); err != nil {
|
2019-04-20 10:39:06 +00:00
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
2019-04-30 03:22:19 +00:00
|
|
|
if _, err := NewVolumeId("a"); err != nil {
|
2019-04-20 10:39:06 +00:00
|
|
|
t.Logf("a is not legal volume id, %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVolumeId_String(t *testing.T) {
|
|
|
|
if str := VolumeId(10).String(); str != "10" {
|
|
|
|
t.Errorf("to string failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
vid := VolumeId(11)
|
|
|
|
if str := vid.String(); str != "11" {
|
|
|
|
t.Errorf("to string failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
pvid := &vid
|
|
|
|
if str := pvid.String(); str != "11" {
|
|
|
|
t.Errorf("to string failed")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVolumeId_Next(t *testing.T) {
|
|
|
|
if vid := VolumeId(10).Next(); vid != VolumeId(11) {
|
|
|
|
t.Errorf("get next volume id failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
vid := VolumeId(11)
|
|
|
|
if new := vid.Next(); new != 12 {
|
|
|
|
t.Errorf("get next volume id failed")
|
|
|
|
}
|
|
|
|
|
|
|
|
pvid := &vid
|
|
|
|
if new := pvid.Next(); new != 12 {
|
|
|
|
t.Errorf("get next volume id failed")
|
|
|
|
}
|
2019-04-30 03:22:19 +00:00
|
|
|
}
|