mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-12-04 18:20:48 +00:00
GetFloat, SetFloat now return error type on error
GetString, SetString now return error type on error SendText now returns error type on error remote_test updated.
This commit is contained in:
parent
e16a51c0da
commit
00f66e8f9e
36
remote.go
36
remote.go
@ -83,36 +83,48 @@ func (r *Remote) Sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets a float parameter value
|
// Gets a float parameter value
|
||||||
func (r *Remote) GetFloat(name string) float64 {
|
func (r *Remote) GetFloat(name string) (float64, error) {
|
||||||
val, err := getParameterFloat(name)
|
val, err := getParameterFloat(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
return 0, err
|
||||||
}
|
}
|
||||||
return val
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets a float paramter value
|
// Sets a float paramter value
|
||||||
func (r *Remote) SetFloat(name string, value float64) {
|
func (r *Remote) SetFloat(name string, value float64) error {
|
||||||
setParameterFloat(name, value)
|
err := setParameterFloat(name, value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a string parameter value
|
// Gets a string parameter value
|
||||||
func (r *Remote) GetString(name string) string {
|
func (r *Remote) GetString(name string) (string, error) {
|
||||||
val, err := getParameterString(name)
|
val, err := getParameterString(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
return "", err
|
||||||
}
|
}
|
||||||
return val
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets a string paramter value
|
// Sets a string paramter value
|
||||||
func (r *Remote) SetString(name, value string) {
|
func (r *Remote) SetString(name, value string) error {
|
||||||
setParameterString(name, value)
|
err := setParameterString(name, value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendText sets multiple parameters by script
|
// SendText sets multiple parameters by script
|
||||||
func (r *Remote) SendText(script string) {
|
func (r *Remote) SendText(script string) error {
|
||||||
setParametersMulti(script)
|
err := setParametersMulti(script)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register forwards the register method to Pooler
|
// Register forwards the register method to Pooler
|
||||||
|
@ -87,18 +87,21 @@ func TestGetPotatoRemote(t *testing.T) {
|
|||||||
func TestSetAndGetFloatParameter(t *testing.T) {
|
func TestSetAndGetFloatParameter(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
var param = "strip[0].mute"
|
var param = "strip[0].mute"
|
||||||
|
var exp = float64(1)
|
||||||
vm.SetFloat(param, 1)
|
vm.SetFloat(param, 1)
|
||||||
t.Run("Should get a float parameter", func(t *testing.T) {
|
t.Run("Should get a float parameter", func(t *testing.T) {
|
||||||
assert.Equal(t, float64(1), vm.GetFloat(param))
|
val, _ := vm.GetFloat(param)
|
||||||
|
assert.Equal(t, exp, val)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetAndGetStringParameter(t *testing.T) {
|
func TestSetAndGetStringParameter(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
var param = "strip[0].label"
|
var param = "strip[0].label"
|
||||||
var val = "test0"
|
var exp = "test0"
|
||||||
vm.SetString(param, val)
|
vm.SetString(param, exp)
|
||||||
t.Run("Should get a string parameter", func(t *testing.T) {
|
t.Run("Should get a string parameter", func(t *testing.T) {
|
||||||
assert.Equal(t, val, vm.GetString(param))
|
val, _ := vm.GetString(param)
|
||||||
|
assert.Equal(t, exp, val)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user