You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
874 B

  1. package needle
  2. import "testing"
  3. func TestNewVolumeId(t *testing.T) {
  4. if _, err := NewVolumeId("1"); err != nil {
  5. t.Error(err)
  6. }
  7. if _, err := NewVolumeId("a"); err != nil {
  8. t.Logf("a is not legal volume id, %v", err)
  9. }
  10. }
  11. func TestVolumeId_String(t *testing.T) {
  12. if str := VolumeId(10).String(); str != "10" {
  13. t.Errorf("to string failed")
  14. }
  15. vid := VolumeId(11)
  16. if str := vid.String(); str != "11" {
  17. t.Errorf("to string failed")
  18. }
  19. pvid := &vid
  20. if str := pvid.String(); str != "11" {
  21. t.Errorf("to string failed")
  22. }
  23. }
  24. func TestVolumeId_Next(t *testing.T) {
  25. if vid := VolumeId(10).Next(); vid != VolumeId(11) {
  26. t.Errorf("get next volume id failed")
  27. }
  28. vid := VolumeId(11)
  29. if new := vid.Next(); new != 12 {
  30. t.Errorf("get next volume id failed")
  31. }
  32. pvid := &vid
  33. if new := pvid.Next(); new != 12 {
  34. t.Errorf("get next volume id failed")
  35. }
  36. }