summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-19 00:08:16 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-19 00:08:16 (GMT)
commit80e141f45e0d017816e7fe41ff4aba6c72f3965e (patch)
treeb171d764fe261bccea0bde976c5dea5c8ab2da7d /src/rhctl
parent82624d4be02ab67c3e35c801ce875b1bb446f8aa (diff)
fixed testcasee after switch command refactoring
Diffstat (limited to 'src/rhctl')
-rw-r--r--src/rhctl/audio_switch_command.go8
-rw-r--r--src/rhctl/audio_switch_command_test.go129
2 files changed, 97 insertions, 40 deletions
diff --git a/src/rhctl/audio_switch_command.go b/src/rhctl/audio_switch_command.go
index a2c5a09..84b7052 100644
--- a/src/rhctl/audio_switch_command.go
+++ b/src/rhctl/audio_switch_command.go
@@ -175,13 +175,13 @@ const (
SwitchCmdAudioFadeUpInput SwitchCmdString = "*uFUii"
SwitchCmdAudioFadeDownInput SwitchCmdString = "*uFDii"
- SwitchCmdOCUnlatch SwitchCmdString = "*uOOcF"
- SwitchCmdOCLatch SwitchCmdString = "*uOOcL"
- SwitchCmdOCPulse SwitchCmdString = "*uOOcP"
-
SwitchCmdRelayUnlatch SwitchCmdString = "*uORrF"
SwitchCmdRelayLatch SwitchCmdString = "*uORrL"
SwitchCmdRelayPulse SwitchCmdString = "*uORrP"
+
+ SwitchCmdOCUnlatch SwitchCmdString = "*uOOcF"
+ SwitchCmdOCLatch SwitchCmdString = "*uOOcL"
+ SwitchCmdOCPulse SwitchCmdString = "*uOOcP"
)
func (c SwitchCmdString) Generate(args ...interface{}) (string, error) {
diff --git a/src/rhctl/audio_switch_command_test.go b/src/rhctl/audio_switch_command_test.go
index 2702565..0192f22 100644
--- a/src/rhctl/audio_switch_command_test.go
+++ b/src/rhctl/audio_switch_command_test.go
@@ -25,133 +25,190 @@ import (
"testing"
)
-func TestSwitchCommandStatus(t *testing.T) {
+func TestSwitchCommandState(t *testing.T) {
var result string
+ var err error
- result = SwitchCmdStatusAudio.Generate(SwitchUnitID(2))
+ if result, err = SwitchCmdStateAudio.Generate(SwitchUnitID(2)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*2SL" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdStatusGPI.Generate(SwitchUnitID(0))
- if result != "*0SPA" {
+ if result, err = SwitchCmdStateSilence.Generate(SwitchUnitID(1)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*1SS" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdStatusOC.Generate(SwitchUnitID(1))
- if result != "*1SO" {
+ if result, err = SwitchCmdStateGPI.Generate(SwitchUnitID(0), SwitchGPINum(4)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*0SP04" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdStatusRelay.Generate(SwitchUnitID(3))
+ if result, err = SwitchCmdStateGPIAll.Generate(SwitchUnitID(0)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*0SPA" {
+ t.Fatalf("wrong output: got '%s'", result)
+ }
+
+ if result, err = SwitchCmdStateRelay.Generate(SwitchUnitID(3)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*3SR" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdStatusSilence.Generate(SwitchUnitID(1))
- if result != "*1SS" {
+ if result, err = SwitchCmdStateOC.Generate(SwitchUnitID(1)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*1SO" {
t.Fatalf("wrong output: got '%s'", result)
}
}
func TestSwitchCommandAudio(t *testing.T) {
var result string
+ var err error
- result = SwitchCmdAudioSelectInput.Generate(SwitchUnitID(0), SwitchInputNum(8), SwitchOutputNum(1))
+ if result, err = SwitchCmdAudioApplyInput.Generate(SwitchUnitID(0), SwitchInputNum(8), SwitchOutputNum(1)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*0081" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioSelectInputAll.Generate(SwitchUnitID(0), SwitchInputNum(3))
+ if result, err = SwitchCmdAudioApplyInputAll.Generate(SwitchUnitID(0), SwitchInputNum(3)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*003A" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioAddInputTo1.Generate(SwitchUnitID(3), SwitchInputNum(4))
+ if result, err = SwitchCmdAudioAddInputTo1.Generate(SwitchUnitID(3), SwitchInputNum(4)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*3043" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioAddInputTo2.Generate(SwitchUnitID(0), SwitchInputNum(0))
- if result != "*0004" {
+ if result, err = SwitchCmdAudioAddInputTo2.Generate(SwitchUnitID(0), SwitchInputNum(1)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*0014" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioRemoveInputFrom1.Generate(SwitchUnitID(2), SwitchInputNum(7))
+ if result, err = SwitchCmdAudioRemoveInputFrom1.Generate(SwitchUnitID(2), SwitchInputNum(7)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*2075" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioRemoveInputFrom2.Generate(SwitchUnitID(1), SwitchInputNum(2))
+ if result, err = SwitchCmdAudioRemoveInputFrom2.Generate(SwitchUnitID(1), SwitchInputNum(2)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*1026" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioMuteInput.Generate(SwitchUnitID(1), SwitchInputNum(2), SwitchOutputNum(2))
+ if result, err = SwitchCmdAudioMuteInput.Generate(SwitchUnitID(1), SwitchInputNum(2), SwitchOutputNum(2)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*102M2" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioMuteInputAll.Generate(SwitchUnitID(1), SwitchInputNum(2))
+ if result, err = SwitchCmdAudioMuteInputAll.Generate(SwitchUnitID(1), SwitchInputNum(2)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*102MA" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioMuteOutput.Generate(SwitchUnitID(0), SwitchOutputNum(1))
+ if result, err = SwitchCmdAudioMuteOutput.Generate(SwitchUnitID(0), SwitchOutputNum(1)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*0M1" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioMuteOutputAll.Generate(SwitchUnitID(3))
+ if result, err = SwitchCmdAudioMuteOutputAll.Generate(SwitchUnitID(3)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*3MA" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioFadeUpInput.Generate(SwitchUnitID(0), SwitchInputNum(3))
+ if result, err = SwitchCmdAudioFadeUpInput.Generate(SwitchUnitID(0), SwitchInputNum(3)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*0FU03" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdAudioFadeDownInput.Generate(SwitchUnitID(1), SwitchInputNum(7))
+ if result, err = SwitchCmdAudioFadeDownInput.Generate(SwitchUnitID(1), SwitchInputNum(7)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
if result != "*1FD07" {
t.Fatalf("wrong output: got '%s'", result)
}
}
-func TestSwitchCommandOC(t *testing.T) {
+func TestSwitchCommandRelay(t *testing.T) {
var result string
+ var err error
- result = SwitchCmdOCUnlatch.Generate(SwitchUnitID(2), SwitchOCNum(3))
- if result != "*2OO3F" {
+ if result, err = SwitchCmdRelayUnlatch.Generate(SwitchUnitID(3), SwitchRelayNum(3)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*3OR3F" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdOCLatch.Generate(SwitchUnitID(3), SwitchOCNum(2))
- if result != "*3OO2L" {
+ if result, err = SwitchCmdRelayLatch.Generate(SwitchUnitID(1), SwitchRelayNum(6)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*1OR6L" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdOCPulse.Generate(SwitchUnitID(0), SwitchOCNum(7))
- if result != "*0OO7P" {
+ if result, err = SwitchCmdRelayPulse.Generate(SwitchUnitID(1), SwitchRelayNum(4)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*1OR4P" {
t.Fatalf("wrong output: got '%s'", result)
}
}
-func TestSwitchCommandRelay(t *testing.T) {
+func TestSwitchCommandOC(t *testing.T) {
var result string
+ var err error
- result = SwitchCmdRelayUnlatch.Generate(SwitchUnitID(3), SwitchRelayNum(3))
- if result != "*3OR3F" {
+ if result, err = SwitchCmdOCUnlatch.Generate(SwitchUnitID(2), SwitchOCNum(3)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*2OO3F" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdRelayLatch.Generate(SwitchUnitID(1), SwitchRelayNum(6))
- if result != "*1OR6L" {
+ if result, err = SwitchCmdOCLatch.Generate(SwitchUnitID(3), SwitchOCNum(2)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*3OO2L" {
t.Fatalf("wrong output: got '%s'", result)
}
- result = SwitchCmdRelayPulse.Generate(SwitchUnitID(1), SwitchRelayNum(4))
- if result != "*1OR4P" {
+ if result, err = SwitchCmdOCPulse.Generate(SwitchUnitID(0), SwitchOCNum(7)); err != nil {
+ t.Fatal("unexpected error:", err)
+ }
+ if result != "*0OO7P" {
t.Fatalf("wrong output: got '%s'", result)
}
}