summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.go (renamed from soundbox.go)12
-rw-r--r--client_test.go25
-rw-r--r--examples_test.go12
-rw-r--r--soundbox_test.go25
4 files changed, 37 insertions, 37 deletions
diff --git a/soundbox.go b/client.go
index d6a0a34..27e5d54 100644
--- a/soundbox.go
+++ b/client.go
@@ -9,23 +9,23 @@ import (
// audio stream data.
const Port = 5316
-type Soundbox struct {
+type Client struct {
HardwareAddr net.HardwareAddr
}
-func NewSoundbox(mac string) (Soundbox, error) {
+func NewClient(mac string) (Client, error) {
hardwareAddr, err := net.ParseMAC(mac)
if err != nil {
- return Soundbox{}, err
+ return Client{}, err
}
return fromHardwareAddr(hardwareAddr)
}
-func fromHardwareAddr(addr net.HardwareAddr) (Soundbox, error) {
+func fromHardwareAddr(addr net.HardwareAddr) (Client, error) {
if len(addr) != 6 {
- return Soundbox{}, fmt.Errorf("Only IEEE 802 MAC-48 addresses supported")
+ return Client{}, fmt.Errorf("Only IEEE 802 MAC-48 addresses supported")
}
- return Soundbox{HardwareAddr: addr}, nil
+ return Client{HardwareAddr: addr}, nil
}
diff --git a/client_test.go b/client_test.go
new file mode 100644
index 0000000..35e3624
--- /dev/null
+++ b/client_test.go
@@ -0,0 +1,25 @@
+package soundbox
+
+import (
+ "testing"
+)
+
+func TestNewClient(t *testing.T) {
+ // valid MAC should succeed
+ _, err := NewClient("12:34:56:ab:cd:ef")
+ if err != nil {
+ t.Fatalf("NewClient() failed: %v", err)
+ }
+
+ // invalid MAC should fail
+ _, err = NewClient("12:34:56:ab:cd")
+ if err == nil {
+ t.Fatalf("NewClient() failed: %v", err)
+ }
+
+ // No EUI-64 supported
+ _, err = NewClient("12:34:56:ab:cd:ef:12:45")
+ if err == nil {
+ t.Fatalf("NewClient() failed: %v", err)
+ }
+}
diff --git a/examples_test.go b/examples_test.go
index 1320cd6..777ae52 100644
--- a/examples_test.go
+++ b/examples_test.go
@@ -7,15 +7,15 @@ import (
"xengineering.eu/soundbox"
)
-// ExampleSoundbox demonstrates how to instantiate a Soundbox struct. The used
-// MAC address if from a private range according to
+// ExampleClient demonstrates how to instantiate a Client struct. The used MAC
+// address if from a private range according to
// https://www.rfc-editor.org/rfc/rfc9542.html#name-48-bit-mac-documentation-va.
-func ExampleSoundbox() {
- s, err := soundbox.NewSoundbox("00:00:5E:00:53:01")
+func ExampleClient() {
+ s, err := soundbox.NewClient("00:00:5E:00:53:01")
if err != nil {
log.Fatal(err)
}
- fmt.Printf("Soundbox with MAC address %v", s.HardwareAddr)
- // Output: Soundbox with MAC address 00:00:5e:00:53:01
+ fmt.Printf("Client with MAC address %v", s.HardwareAddr)
+ // Output: Client with MAC address 00:00:5e:00:53:01
}
diff --git a/soundbox_test.go b/soundbox_test.go
deleted file mode 100644
index ee9d885..0000000
--- a/soundbox_test.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package soundbox
-
-import (
- "testing"
-)
-
-func TestNewSoundbox(t *testing.T) {
- // valid MAC should succeed
- _, err := NewSoundbox("12:34:56:ab:cd:ef")
- if err != nil {
- t.Fatalf("NewSoundbox() failed: %v", err)
- }
-
- // invalid MAC should fail
- _, err = NewSoundbox("12:34:56:ab:cd")
- if err == nil {
- t.Fatalf("NewSoundbox() failed: %v", err)
- }
-
- // No EUI-64 supported
- _, err = NewSoundbox("12:34:56:ab:cd:ef:12:45")
- if err == nil {
- t.Fatalf("NewSoundbox() failed: %v", err)
- }
-}