1
#include <gtest/gtest.h>
4
#include "controllers/midi/portmidienumerator.h"
6
class PortMidiEnumeratorTest : public testing::Test {
11
virtual void TearDown() {
15
TEST_F(PortMidiEnumeratorTest, InputOutputPortsLinked) {
16
// Identical device names should link.
17
ASSERT_TRUE(shouldLinkInputToOutput(
21
// Different device names should not link.
22
ASSERT_FALSE(shouldLinkInputToOutput(
26
// Ports with From or To in them that are otherwise equal should link.
27
ASSERT_TRUE(shouldLinkInputToOutput(
28
"From: Vestax VCI-100",
29
"To: Vestax VCI-100"));
31
// Ports with From or To in them that are otherwise equal should link. Case
33
ASSERT_TRUE(shouldLinkInputToOutput(
34
"frOm: Vestax VCI-100",
35
"tO: Vestax VCI-100"));
37
// Ports that match the pattern "$DEVICE MIDI $INSTANCE ..." should link.
39
ASSERT_TRUE(shouldLinkInputToOutput(
40
"Vestax VCI-100 MIDI 1",
41
"Vestax VCI-100 MIDI 1"));
43
// Stuff after $INSTANCE doesn't matter.
44
ASSERT_TRUE(shouldLinkInputToOutput(
45
"Vestax VCI-100 MIDI 1 OtherJunk",
46
"Vestax VCI-100 MIDI 1 123 Doesn't Matter"));
48
// Name is case-insensitive.
49
ASSERT_TRUE(shouldLinkInputToOutput(
50
"Vestax VCI-100 MIDI 1 OtherJunk",
51
"VesTaX VCI-100 MIDI 1 123 Doesn't Matter"));
53
// Different $INSTANCE matters.
54
ASSERT_FALSE(shouldLinkInputToOutput(
55
"Vestax VCI-100 MIDI 1 OtherJunk",
56
"Vestax VCI-100 MIDI 2 123 Doesn't Matter"));
58
// Different $INSTANCE with no trailing stuff matters.
59
ASSERT_FALSE(shouldLinkInputToOutput(
60
"Vestax VCI-100 MIDI 1",
61
"Vestax VCI-100 MIDI 12"));
63
// Extra stuff only on one doesn't matter.
64
ASSERT_TRUE(shouldLinkInputToOutput(
65
"Vestax VCI-100 MIDI 12",
66
"Vestax VCI-100 MIDI 12 123 Something Else"));
68
// Dangling numerals after the device name but before MIDI are fine.
69
ASSERT_TRUE(shouldLinkInputToOutput(
70
"Vestax VCI-100 2 MIDI 12",
71
"Vestax VCI-100 2 MIDI 12 123 Something Else"));
73
// Different $DEVICE matters.
74
ASSERT_FALSE(shouldLinkInputToOutput(
75
"Vestax VCI-100 MIDI 1",
76
"Vestax VCI-300 MIDI 1"));
78
// Non-numeral extra stuff following a lone numeral after the device name
80
ASSERT_TRUE(shouldLinkInputToOutput(
81
"nanoKONTROL2 1 CTRL",
82
"nanoKONTROL2 1 SLIDER/KNOB"));
84
// Extra stuff with a numeral following a lone numeral after the device name
85
// doesn't get linked.
86
ASSERT_FALSE(shouldLinkInputToOutput(
87
"nanoKONTROL2 1 1 CTRL",
88
"nanoKONTROL2 1 SLIDER/KNOB"));
90
// If the device name has a numeral dangling off of it we should not get
92
ASSERT_FALSE(shouldLinkInputToOutput(
93
"nanoKONTROL 2 1 CTRL",
94
"nanoKONTROL 2 3 SLIDER/KNOB"));