|
| 1 | +// SPDX-FileCopyrightText: Copyright (C) Kushview, LLC. |
| 2 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | + |
| 4 | +#include <boost/test/unit_test.hpp> |
| 5 | + |
| 6 | +#include "nodes/midimonitor.hpp" |
| 7 | +#include "utils.hpp" |
| 8 | + |
| 9 | +using namespace element; |
| 10 | +using namespace juce; |
| 11 | + |
| 12 | +BOOST_AUTO_TEST_SUITE (MidiMonitorTests) |
| 13 | + |
| 14 | +BOOST_AUTO_TEST_CASE (NoteOnUsesMiddleCAsC4) |
| 15 | +{ |
| 16 | + const auto text = MidiMonitorNode::describe (MidiMessage::noteOn (1, 60, 1.0f)); |
| 17 | + BOOST_REQUIRE (text.startsWith ("Note On C4")); |
| 18 | + BOOST_REQUIRE (text.contains ("(60)")); |
| 19 | + BOOST_REQUIRE (text.contains ("Channel 1")); |
| 20 | +} |
| 21 | + |
| 22 | +BOOST_AUTO_TEST_CASE (NoteNamesAtOctaveEdges) |
| 23 | +{ |
| 24 | + BOOST_REQUIRE (MidiMonitorNode::describe (MidiMessage::noteOn (1, 21, 1.0f)) |
| 25 | + .startsWith ("Note On A0")); |
| 26 | + BOOST_REQUIRE (MidiMonitorNode::describe (MidiMessage::noteOn (1, 0, 1.0f)) |
| 27 | + .startsWith ("Note On C-1")); |
| 28 | + BOOST_REQUIRE (MidiMonitorNode::describe (MidiMessage::noteOn (1, 127, 1.0f)) |
| 29 | + .startsWith ("Note On G9")); |
| 30 | +} |
| 31 | + |
| 32 | +BOOST_AUTO_TEST_CASE (NoteOff) |
| 33 | +{ |
| 34 | + const auto text = MidiMonitorNode::describe (MidiMessage::noteOff (2, 60)); |
| 35 | + BOOST_REQUIRE (text.startsWith ("Note Off C4")); |
| 36 | + BOOST_REQUIRE (text.contains ("Channel 2")); |
| 37 | +} |
| 38 | + |
| 39 | +BOOST_AUTO_TEST_CASE (ClockIsNotLogged) |
| 40 | +{ |
| 41 | + BOOST_REQUIRE (MidiMonitorNode::describe (MidiMessage::midiClock()).isEmpty()); |
| 42 | +} |
| 43 | + |
| 44 | +BOOST_AUTO_TEST_CASE (TransportMessagesLogOnce) |
| 45 | +{ |
| 46 | + BOOST_REQUIRE_EQUAL (MidiMonitorNode::describe (MidiMessage::midiStart()).toStdString(), "Start"); |
| 47 | + BOOST_REQUIRE_EQUAL (MidiMonitorNode::describe (MidiMessage::midiStop()).toStdString(), "Stop"); |
| 48 | + BOOST_REQUIRE_EQUAL (MidiMonitorNode::describe (MidiMessage::midiContinue()).toStdString(), "Continue"); |
| 49 | +} |
| 50 | + |
| 51 | +BOOST_AUTO_TEST_CASE (AgreesWithNoteValueConversions) |
| 52 | +{ |
| 53 | + BOOST_REQUIRE_EQUAL (Util::middleCOctave, 4); |
| 54 | + BOOST_REQUIRE_EQUAL (Util::noteValueToString (60).toStdString(), "C4"); |
| 55 | + BOOST_REQUIRE_EQUAL (Util::noteValueToString (21).toStdString(), "A0"); |
| 56 | + BOOST_REQUIRE_EQUAL (Util::noteValueFromString ("C4"), 60); |
| 57 | + BOOST_REQUIRE_EQUAL (Util::noteValueFromString ("A0"), 21); |
| 58 | + BOOST_REQUIRE_EQUAL (Util::noteValueFromString ("C-1"), 0); |
| 59 | + BOOST_REQUIRE_EQUAL (Util::noteValueFromString ("G9"), 127); |
| 60 | +} |
| 61 | + |
| 62 | +BOOST_AUTO_TEST_SUITE_END() |
0 commit comments