mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-22 04:40:53 +00:00
added unit tests for factory functions.
This commit is contained in:
parent
479e0e1a19
commit
bbbb62a0c1
@ -111,7 +111,7 @@ func mdirty() bool {
|
||||
}
|
||||
|
||||
func sync() {
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
for pdirty() || mdirty() {
|
||||
}
|
||||
}
|
||||
@ -151,7 +151,7 @@ func getParameterFloat(name string) float64 {
|
||||
return math.Round(float64(value)*10) / 10
|
||||
}
|
||||
|
||||
// getParameterFloat sets the value of a float parameter
|
||||
// setParameterFloat sets the value of a float parameter
|
||||
func setParameterFloat(name string, value float32) {
|
||||
b1 := append([]byte(name), 0)
|
||||
b2 := math.Float32bits(value)
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
type t_bus interface {
|
||||
String() string
|
||||
GetMute() bool
|
||||
SetMute(val bool)
|
||||
GetEq() bool
|
||||
@ -23,14 +24,6 @@ type bus struct {
|
||||
iRemote
|
||||
}
|
||||
|
||||
// String implements the stringer interface
|
||||
func (b *bus) String() string {
|
||||
if b.index < b.kind.physOut {
|
||||
return fmt.Sprintf("PhysicalBus%d\n", b.index)
|
||||
}
|
||||
return fmt.Sprintf("VirtualBus%d\n", b.index)
|
||||
}
|
||||
|
||||
// GetMute returns the value of the Mute parameter
|
||||
func (b *bus) GetMute() bool {
|
||||
return b.getter_bool("Mute")
|
||||
@ -85,16 +78,26 @@ type physicalBus struct {
|
||||
bus
|
||||
}
|
||||
|
||||
func newPhysicalBus(i int, k *kind) t_bus {
|
||||
pb := physicalBus{bus{iRemote{"bus", i, k}}}
|
||||
func newPhysicalBus(i int) t_bus {
|
||||
pb := physicalBus{bus{iRemote{"bus", i}}}
|
||||
return t_bus(&pb)
|
||||
}
|
||||
|
||||
// String implements the stringer interface
|
||||
func (p *physicalBus) String() string {
|
||||
return fmt.Sprintf("PhysicalBus%d", p.index)
|
||||
}
|
||||
|
||||
type virtualBus struct {
|
||||
bus
|
||||
}
|
||||
|
||||
func newVirtualBus(i int, k *kind) t_bus {
|
||||
vb := virtualBus{bus{iRemote{"bus", i, k}}}
|
||||
func newVirtualBus(i int) t_bus {
|
||||
vb := virtualBus{bus{iRemote{"bus", i}}}
|
||||
return t_bus(&vb)
|
||||
}
|
||||
|
||||
// String implements the stringer interface
|
||||
func (v *virtualBus) String() string {
|
||||
return fmt.Sprintf("VirtualBus%d", v.index)
|
||||
}
|
||||
|
29
voicemeeter/bus_test.go
Normal file
29
voicemeeter/bus_test.go
Normal file
@ -0,0 +1,29 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetPhysBus(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__bus := newPhysicalBus(0)
|
||||
t.Run("Should return a physical bus type", func(t *testing.T) {
|
||||
assert.NotNil(t, __bus)
|
||||
})
|
||||
t.Run("Should return 'PhysicalBus0'", func(t *testing.T) {
|
||||
assert.Equal(t, "PhysicalBus0", __bus.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetVirtBus(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__bus := newVirtualBus(4)
|
||||
t.Run("Should return a basic kind", func(t *testing.T) {
|
||||
assert.NotNil(t, __bus)
|
||||
})
|
||||
t.Run("Should return 'VirtualBus4'", func(t *testing.T) {
|
||||
assert.Equal(t, "VirtualBus4", __bus.String())
|
||||
})
|
||||
}
|
@ -30,7 +30,7 @@ func (m *button) setter(v bool, mode int) {
|
||||
|
||||
// String implements the stringer interface
|
||||
func (m *button) String() string {
|
||||
return fmt.Sprintf("MacroButton%d\n", m.index)
|
||||
return fmt.Sprintf("MacroButton%d", m.index)
|
||||
}
|
||||
|
||||
// GetState returns the value of the State parameter
|
||||
|
15
voicemeeter/button_test.go
Normal file
15
voicemeeter/button_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetButton(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__mb := newButton(0)
|
||||
t.Run("Should return a button type", func(t *testing.T) {
|
||||
assert.NotNil(t, __mb)
|
||||
})
|
||||
}
|
15
voicemeeter/command_test.go
Normal file
15
voicemeeter/command_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetCommand(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__c := newCommand()
|
||||
t.Run("Should return a command type", func(t *testing.T) {
|
||||
assert.NotNil(t, __c)
|
||||
})
|
||||
}
|
@ -8,7 +8,6 @@ import (
|
||||
type iRemote struct {
|
||||
_identifier string
|
||||
index int
|
||||
kind *kind
|
||||
}
|
||||
|
||||
func (c *iRemote) identifier() string {
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var basic, banana, potato *kind
|
||||
|
||||
// A kind represents a Voicemeeter kinds layout
|
||||
type kind struct {
|
||||
name string
|
||||
@ -27,17 +29,26 @@ func (k *kind) String() string {
|
||||
|
||||
// newBasicKind returns a basic kind struct address
|
||||
func newBasicKind() *kind {
|
||||
return &kind{"basic", 2, 1, 1, 1, 4, 4}
|
||||
if basic == nil {
|
||||
basic = &kind{"basic", 2, 1, 1, 1, 4, 4}
|
||||
}
|
||||
return basic
|
||||
}
|
||||
|
||||
// newBananaKind returns a banana kind struct address
|
||||
func newBananaKind() *kind {
|
||||
return &kind{"banana", 3, 2, 3, 2, 8, 8}
|
||||
if banana == nil {
|
||||
banana = &kind{"banana", 3, 2, 3, 2, 8, 8}
|
||||
}
|
||||
return banana
|
||||
}
|
||||
|
||||
// newPotatoKind returns a potato kind struct address
|
||||
func newPotatoKind() *kind {
|
||||
return &kind{"potato", 5, 3, 5, 3, 8, 8}
|
||||
if potato == nil {
|
||||
potato = &kind{"potato", 5, 3, 5, 3, 8, 8}
|
||||
}
|
||||
return potato
|
||||
}
|
||||
|
||||
var (
|
||||
|
40
voicemeeter/kinds_test.go
Normal file
40
voicemeeter/kinds_test.go
Normal file
@ -0,0 +1,40 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetKindBasic(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__kind := newBasicKind()
|
||||
t.Run("Should return a basic kind", func(t *testing.T) {
|
||||
assert.NotNil(t, __kind)
|
||||
})
|
||||
t.Run("Should equal 'Basic'", func(t *testing.T) {
|
||||
assert.Equal(t, "Basic", __kind.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetKindBanana(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__kind := newBananaKind()
|
||||
t.Run("Should return a banana kind", func(t *testing.T) {
|
||||
assert.NotNil(t, __kind)
|
||||
})
|
||||
t.Run("Should return 'Banana'", func(t *testing.T) {
|
||||
assert.Equal(t, "Banana", __kind.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetKindPotato(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__kind := newPotatoKind()
|
||||
t.Run("Should return a potato kind", func(t *testing.T) {
|
||||
assert.NotNil(t, __kind)
|
||||
})
|
||||
t.Run("Should return 'Potato'", func(t *testing.T) {
|
||||
assert.Equal(t, "Potato", __kind.String())
|
||||
})
|
||||
}
|
15
voicemeeter/path_test.go
Normal file
15
voicemeeter/path_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetVMPath(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
_, err := dllPath()
|
||||
t.Run("Should return err as nil", func(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
})
|
||||
}
|
@ -52,19 +52,19 @@ func NewRemote(kindId string) *remote {
|
||||
}
|
||||
|
||||
_strip := make([]t_strip, _kind.numStrip())
|
||||
for i := 0; i < _kind.physIn+_kind.virtIn; i++ {
|
||||
for i := 0; i < _kind.numStrip(); i++ {
|
||||
if i < _kind.physIn {
|
||||
_strip[i] = newPhysicalStrip(i, _kind)
|
||||
_strip[i] = newPhysicalStrip(i)
|
||||
} else {
|
||||
_strip[i] = newVirtualStrip(i, _kind)
|
||||
_strip[i] = newVirtualStrip(i)
|
||||
}
|
||||
}
|
||||
_bus := make([]t_bus, _kind.numBus())
|
||||
for i := 0; i < _kind.physOut+_kind.virtOut; i++ {
|
||||
for i := 0; i < _kind.numBus(); i++ {
|
||||
if i < _kind.physOut {
|
||||
_bus[i] = newPhysicalBus(i, _kind)
|
||||
_bus[i] = newPhysicalBus(i)
|
||||
} else {
|
||||
_bus[i] = newVirtualBus(i, _kind)
|
||||
_bus[i] = newVirtualBus(i)
|
||||
}
|
||||
}
|
||||
_button := make([]button, 80)
|
||||
|
58
voicemeeter/remote_test.go
Normal file
58
voicemeeter/remote_test.go
Normal file
@ -0,0 +1,58 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetBasicRemote(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__rem := NewRemote("basic")
|
||||
t.Run("Should return a remote basic type", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem)
|
||||
})
|
||||
t.Run("Should equal 'Voicemeeter Basic'", func(t *testing.T) {
|
||||
assert.Equal(t, "Voicemeeter Basic", __rem.String())
|
||||
})
|
||||
t.Run("Should strip length equal 3", func(t *testing.T) {
|
||||
assert.Equal(t, 3, len(__rem.Strip))
|
||||
})
|
||||
t.Run("Should bus length equal 2", func(t *testing.T) {
|
||||
assert.Equal(t, 2, len(__rem.Bus))
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetBananaRemote(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__rem := NewRemote("banana")
|
||||
t.Run("Should return a remote banana type", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem)
|
||||
})
|
||||
t.Run("Should equal 'Voicemeeter Banana'", func(t *testing.T) {
|
||||
assert.Equal(t, "Voicemeeter Banana", __rem.String())
|
||||
})
|
||||
t.Run("Should strip length equal 5", func(t *testing.T) {
|
||||
assert.Equal(t, 5, len(__rem.Strip))
|
||||
})
|
||||
t.Run("Should bus length equal 5", func(t *testing.T) {
|
||||
assert.Equal(t, 5, len(__rem.Bus))
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetPotatoRemote(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__rem := NewRemote("potato")
|
||||
t.Run("Should return a remote basic type", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem)
|
||||
})
|
||||
t.Run("Should equal 'Voicemeeter Potato'", func(t *testing.T) {
|
||||
assert.Equal(t, "Voicemeeter Potato", __rem.String())
|
||||
})
|
||||
t.Run("Should strip length equal 8", func(t *testing.T) {
|
||||
assert.Equal(t, 8, len(__rem.Strip))
|
||||
})
|
||||
t.Run("Should bus length equal 8", func(t *testing.T) {
|
||||
assert.Equal(t, 8, len(__rem.Bus))
|
||||
})
|
||||
}
|
@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
type t_strip interface {
|
||||
String() string
|
||||
GetMute() bool
|
||||
SetMute(val bool)
|
||||
GetMono() bool
|
||||
@ -33,14 +34,6 @@ type strip struct {
|
||||
iRemote
|
||||
}
|
||||
|
||||
// implement stringer interface in fmt
|
||||
func (s *strip) String() string {
|
||||
if s.index < s.kind.physIn {
|
||||
return fmt.Sprintf("PhysicalStrip%d\n", s.index)
|
||||
}
|
||||
return fmt.Sprintf("VirtualStrip%d\n", s.index)
|
||||
}
|
||||
|
||||
// GetMute returns the value of the Mute parameter
|
||||
func (s *strip) GetMute() bool {
|
||||
return s.getter_bool("Mute")
|
||||
@ -105,11 +98,16 @@ type physicalStrip struct {
|
||||
strip
|
||||
}
|
||||
|
||||
func newPhysicalStrip(i int, k *kind) t_strip {
|
||||
ps := physicalStrip{strip{iRemote{"strip", i, k}}}
|
||||
func newPhysicalStrip(i int) t_strip {
|
||||
ps := physicalStrip{strip{iRemote{"strip", i}}}
|
||||
return t_strip(&ps)
|
||||
}
|
||||
|
||||
// implement stringer interface in fmt
|
||||
func (p *physicalStrip) String() string {
|
||||
return fmt.Sprintf("PhysicalStrip%d", p.index)
|
||||
}
|
||||
|
||||
// GetComp returns the value of the Comp parameter
|
||||
func (p *physicalStrip) GetComp() bool {
|
||||
return p.getter_bool("Comp")
|
||||
@ -154,11 +152,16 @@ type virtualStrip struct {
|
||||
strip
|
||||
}
|
||||
|
||||
func newVirtualStrip(i int, k *kind) t_strip {
|
||||
vs := virtualStrip{strip{iRemote{"strip", i, k}}}
|
||||
func newVirtualStrip(i int) t_strip {
|
||||
vs := virtualStrip{strip{iRemote{"strip", i}}}
|
||||
return t_strip(&vs)
|
||||
}
|
||||
|
||||
// implement stringer interface in fmt
|
||||
func (v *virtualStrip) String() string {
|
||||
return fmt.Sprintf("VirtualStrip%d", v.index)
|
||||
}
|
||||
|
||||
// GetMc returns the value of the MC parameter
|
||||
func (v *virtualStrip) GetMc() bool {
|
||||
return v.getter_bool("MC")
|
||||
|
29
voicemeeter/strip_test.go
Normal file
29
voicemeeter/strip_test.go
Normal file
@ -0,0 +1,29 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetPhysStrip(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__strip := newPhysicalStrip(0)
|
||||
t.Run("Should return a physical strip type", func(t *testing.T) {
|
||||
assert.NotNil(t, __strip)
|
||||
})
|
||||
t.Run("Should return 'PhysicalStrip0'", func(t *testing.T) {
|
||||
assert.Equal(t, "PhysicalStrip0", __strip.String())
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetVirtStrip(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__strip := newVirtualStrip(4)
|
||||
t.Run("Should return a basic kind", func(t *testing.T) {
|
||||
assert.NotNil(t, __strip)
|
||||
})
|
||||
t.Run("Should return 'VirtualStrip4'", func(t *testing.T) {
|
||||
assert.Equal(t, "VirtualStrip4", __strip.String())
|
||||
})
|
||||
}
|
@ -23,8 +23,8 @@ type vbanInStream struct {
|
||||
vbanStream
|
||||
}
|
||||
|
||||
func newVbanInStream(i int, k *kind) t_vban {
|
||||
vbi := vbanInStream{vbanStream{iRemote{"vban.instream", i, k}}}
|
||||
func newVbanInStream(i int) t_vban {
|
||||
vbi := vbanInStream{vbanStream{iRemote{"vban.instream", i}}}
|
||||
return t_vban(&vbi)
|
||||
}
|
||||
|
||||
@ -32,8 +32,8 @@ type vbanOutStream struct {
|
||||
vbanStream
|
||||
}
|
||||
|
||||
func newVbanOutStream(i int, k *kind) t_vban {
|
||||
vbo := vbanOutStream{vbanStream{iRemote{"vban.outstream", i, k}}}
|
||||
func newVbanOutStream(i int) t_vban {
|
||||
vbo := vbanOutStream{vbanStream{iRemote{"vban.outstream", i}}}
|
||||
return t_vban(&vbo)
|
||||
}
|
||||
|
||||
@ -45,11 +45,11 @@ type vban struct {
|
||||
func newVban(k *kind) *vban {
|
||||
_vbanIn := make([]t_vban, k.vbanIn)
|
||||
for i := 0; i < k.vbanIn; i++ {
|
||||
_vbanIn[i] = newVbanInStream(i, k)
|
||||
_vbanIn[i] = newVbanInStream(i)
|
||||
}
|
||||
_vbanOut := make([]t_vban, k.vbanOut)
|
||||
for i := 0; i < k.vbanOut; i++ {
|
||||
_vbanOut[i] = newVbanOutStream(i, k)
|
||||
_vbanOut[i] = newVbanOutStream(i)
|
||||
}
|
||||
return &vban{
|
||||
InStream: _vbanIn,
|
||||
|
23
voicemeeter/vban_test.go
Normal file
23
voicemeeter/vban_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
package voicemeeter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetVbanInStream(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__vbi := newVbanInStream(0)
|
||||
t.Run("Should return a vban instream type", func(t *testing.T) {
|
||||
assert.NotNil(t, __vbi)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetVbanOutStream(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
__vbo := newVbanOutStream(0)
|
||||
t.Run("Should return a vban outstream type", func(t *testing.T) {
|
||||
assert.NotNil(t, __vbo)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user