Skip to content

Commit

Permalink
Merge branch 'Team254:main' into 2025-Sussex-Scrimmage
Browse files Browse the repository at this point in the history
  • Loading branch information
yeojwal authored Dec 28, 2024
2 parents 7bd229c + 2baa45c commit d597612
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This software may be used and redistributed subject to the following conditions:
1. The software may be used without restriction for testing, scrimmages,
off-season events, and for evaluation purposes.
2. The software may be modified for such use, but the modifications may not be
redistributed.
redistributed without permission from Team 254.
3. Redistribution for the purpose of contributing to the original project (e.g.
forking on GitHub and submitting pull requests) is permitted.

Expand Down
9 changes: 6 additions & 3 deletions partner/blackmagic.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ type BlackmagicClient struct {

// Creates a new Blackmagic client with the given device addresses as a comma-separated string.
func NewBlackmagicClient(addresses string) *BlackmagicClient {
deviceAddresses := strings.Split(addresses, ",")
for i, address := range deviceAddresses {
deviceAddresses[i] = strings.TrimSpace(address)
var deviceAddresses []string
for _, address := range strings.Split(addresses, ",") {
trimmedAddress := strings.TrimSpace(address)
if trimmedAddress != "" {
deviceAddresses = append(deviceAddresses, trimmedAddress)
}
}
return &BlackmagicClient{deviceAddresses: deviceAddresses}
}
Expand Down
32 changes: 32 additions & 0 deletions partner/blackmagic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2024 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)

package partner

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestNewBlackmagicClient(t *testing.T) {
// Test with an empty address.
client := NewBlackmagicClient("")
assert.Equal(t, 0, len(client.deviceAddresses))

// Test with whitespace in the address.
client = NewBlackmagicClient(" ")
assert.Equal(t, 0, len(client.deviceAddresses))

// Test with a single address.
client = NewBlackmagicClient("1.2.3.4")
if assert.Equal(t, 1, len(client.deviceAddresses)) {
assert.Equal(t, "1.2.3.4", client.deviceAddresses[0])
}

// Test with multiple addresses.
client = NewBlackmagicClient(" 1.2.3.4 , 5.6.7.8 ")
if assert.Equal(t, 2, len(client.deviceAddresses)) {
assert.Equal(t, "1.2.3.4", client.deviceAddresses[0])
assert.Equal(t, "5.6.7.8", client.deviceAddresses[1])
}
}

0 comments on commit d597612

Please sign in to comment.