Skip to content

Commit 08afb74

Browse files
oflebbedeadprogram
authored andcommitted
add more test, fix uuid test (strings are lower case in implementation)
1 parent 5bedd1d commit 08afb74

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

uuid_test.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
package bluetooth
22

3-
import "testing"
3+
import (
4+
"testing"
5+
)
46

57
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")
79
}
810

911
func checkUUID(t *testing.T, uuid UUID, check string) {
1012
if uuid.String() != check {
1113
t.Errorf("expected UUID %s but got %s", check, uuid.String())
1214
}
1315
}
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

Comments
 (0)