|
1 | 1 | package bluetooth |
2 | 2 |
|
3 | | -import "testing" |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | +) |
4 | 6 |
|
5 | 7 | func TestUUIDString(t *testing.T) { |
6 | | - checkUUID(t, New16BitUUID(0x1234), "00001234-0000-1000-8000-00805F9B34FB") |
| 8 | + checkUUID(t, New16BitUUID(0x1234), "00001234-0000-1000-8000-00805f9b34fb") |
7 | 9 | } |
8 | 10 |
|
9 | 11 | func checkUUID(t *testing.T, uuid UUID, check string) { |
10 | 12 | if uuid.String() != check { |
11 | 13 | t.Errorf("expected UUID %s but got %s", check, uuid.String()) |
12 | 14 | } |
13 | 15 | } |
| 16 | + |
| 17 | +func TestParseUUIDTooSmall(t *testing.T) { |
| 18 | + _, e := ParseUUID("00001234-0000-1000-8000-00805f9b34f") |
| 19 | + if e != errInvalidUUID { |
| 20 | + t.Errorf("expected errInvalidUUID but got %v", e) |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +func TestParseUUIDTooLarge(t *testing.T) { |
| 25 | + _, e := ParseUUID("00001234-0000-1000-8000-00805F9B34FB0") |
| 26 | + if e != errInvalidUUID { |
| 27 | + t.Errorf("expected errInvalidUUID but got %v", e) |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +func TestStringUUID(t *testing.T) { |
| 32 | + uuidString := "00001234-0000-1000-8000-00805f9b34fb" |
| 33 | + u, e := ParseUUID(uuidString) |
| 34 | + if e != nil { |
| 35 | + t.Errorf("expected nil but got %v", e) |
| 36 | + } |
| 37 | + if u.String() != uuidString { |
| 38 | + t.Errorf("expected %s but got %s", uuidString, u.String()) |
| 39 | + } |
| 40 | +} |
0 commit comments