-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix gaps in Blackmagic address parsing (fixes #206).
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
} | ||
} |