PageRenderTime 221ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/bluez/gatt_tool_test.go

https://gitlab.com/brucealdridge/driver-go-blecombined
Go | 42 lines | 30 code | 12 blank | 0 comment | 10 complexity | 6e349a8a4caeda9ae0ddfa923e33db8d MD5 | raw file
  1. package bluez
  2. import (
  3. "encoding/hex"
  4. "testing"
  5. )
  6. const (
  7. sampleReadResult = "022d00d0d09e38a534ddb8c04f04685213a78d"
  8. )
  9. func TestCharacteristicsRegex(t *testing.T) {
  10. line := "handle = 0x0002, char properties = 0x0a, char value handle = 0x0003, uuid = 00002a00-0000-1000-8000-00805f9b34fb"
  11. params := getAttributes(line)
  12. if params["handle"] != "0x0002" {
  13. t.Errorf("bad handle %v", params["handle"])
  14. }
  15. if params["char_value_handle"] != "0x0003" {
  16. t.Errorf("bad char_value_handle %v", params["char_value_handle"])
  17. }
  18. if params["uuid"] != "00002a00-0000-1000-8000-00805f9b34fb" {
  19. t.Errorf("bad characteristic uuid %v", params["uuid"])
  20. }
  21. }
  22. func TestHexDecode(t *testing.T) {
  23. payload, err := hex.DecodeString(sampleReadResult)
  24. if err != nil {
  25. t.Error(err)
  26. }
  27. if len(payload) != 19 {
  28. t.Errorf("bad payload %x", payload)
  29. }
  30. }