add more test, fix uuid test (strings are lower case in implementation)
This commit is contained in:
parent
5bedd1dccc
commit
08afb74cfc
1 changed files with 29 additions and 2 deletions
31
uuid_test.go
31
uuid_test.go
|
@ -1,9 +1,11 @@
|
|||
package bluetooth
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUUIDString(t *testing.T) {
|
||||
checkUUID(t, New16BitUUID(0x1234), "00001234-0000-1000-8000-00805F9B34FB")
|
||||
checkUUID(t, New16BitUUID(0x1234), "00001234-0000-1000-8000-00805f9b34fb")
|
||||
}
|
||||
|
||||
func checkUUID(t *testing.T, uuid UUID, check string) {
|
||||
|
@ -11,3 +13,28 @@ func checkUUID(t *testing.T, uuid UUID, check string) {
|
|||
t.Errorf("expected UUID %s but got %s", check, uuid.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseUUIDTooSmall(t *testing.T) {
|
||||
_, e := ParseUUID("00001234-0000-1000-8000-00805f9b34f")
|
||||
if e != errInvalidUUID {
|
||||
t.Errorf("expected errInvalidUUID but got %v", e)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseUUIDTooLarge(t *testing.T) {
|
||||
_, e := ParseUUID("00001234-0000-1000-8000-00805F9B34FB0")
|
||||
if e != errInvalidUUID {
|
||||
t.Errorf("expected errInvalidUUID but got %v", e)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringUUID(t *testing.T) {
|
||||
uuidString := "00001234-0000-1000-8000-00805f9b34fb"
|
||||
u, e := ParseUUID(uuidString)
|
||||
if e != nil {
|
||||
t.Errorf("expected nil but got %v", e)
|
||||
}
|
||||
if u.String() != uuidString {
|
||||
t.Errorf("expected %s but got %s", uuidString, u.String())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue