[41]:... unit tests for sender and receiver errors#65
Merged
gavv merged 8 commits intoMar 28, 2023
Merged
Conversation
Contributor
Author
Collaborator
Member
|
Also @Asalle |
Member
|
Nice work! a couple of tests could be added:
also, point for discussion (@gavv ): Maybe add test func TestReceiver_Closed(t *testing.T) {
tests := []struct {
name string
operation func(receiver *Receiver) error
}{
{
name: "SetMulticastGroup after close",
operation: func(receiver *Receiver) error {
return receiver.SetMulticastGroup(SlotDefault, InterfaceAudioSource, "127.0.0.1")
},
},
{
name: "Bind after close",
operation: func(receiver *Receiver) error {
return receiver.Bind(SlotDefault, InterfaceAudioSource, nil)
},
},
{
name: "ReadFloats after close",
operation: func(receiver *Receiver) error {
recFloats := make([]float32, 2)
return receiver.ReadFloats(recFloats)
},
},
}
for _, tt := range tests {
ctx, err := OpenContext(ContextConfig{})
require.NoError(t, err)
require.NotNil(t, ctx)
receiver, err := OpenReceiver(ctx, makeReceiverConfig())
require.NoError(t, err)
require.NotNil(t, receiver)
err = receiver.Close()
require.NoError(t, err)
require.Equal(t, errors.New("receiver is closed"), tt.operation(receiver))
err = ctx.Close()
require.NoError(t, err)
}
} |
Member
|
I agree with Andrey, separating this check will make the table tests more uniform, which is the point of tables. Ideally table tests should have minimal amount of conditions and if tests have rather different flow, they should belong to different tables / tests. |
Contributor
Author
ortex
reviewed
Mar 28, 2023
ortex
approved these changes
Mar 28, 2023
Member
|
Thanks! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR for #41
Implemented
TestReceiver_BindTestReceiver_ReadFloatsTestSender_ConnectTestSender_WriteFloats