summaryrefslogtreecommitdiff
path: root/test/midimapparsertest.cc
diff options
context:
space:
mode:
authorSander Vocke <sandervocke@gmail.com>2024-07-25 09:09:35 +0200
committerSander Vocke <sandervocke@gmail.com>2024-07-25 11:06:32 +0200
commit624aafbc9cde2b9e83c7c278e44f19ab9e3bc9fc (patch)
treef6e2ef7329b32e4601326012221e0b5ce64a0367 /test/midimapparsertest.cc
parent019d478818950f7880d2c0f80d8fc8f963e9736b (diff)
Support curve maps in midi map file
Diffstat (limited to 'test/midimapparsertest.cc')
-rw-r--r--test/midimapparsertest.cc50
1 files changed, 46 insertions, 4 deletions
diff --git a/test/midimapparsertest.cc b/test/midimapparsertest.cc
index 3e77c44..0b892e9 100644
--- a/test/midimapparsertest.cc
+++ b/test/midimapparsertest.cc
@@ -27,6 +27,7 @@
#include <uunit.h>
#include <midimapparser.h>
+#include <curvemap.h>
#include "scopedfile.h"
@@ -36,11 +37,12 @@ class MidimapParserTest
public:
MidimapParserTest()
{
- uTEST(MidimapParserTest::test);
- uTEST(MidimapParserTest::invalid);
+ uTEST(MidimapParserTest::test_basic);
+ uTEST(MidimapParserTest::test_curve);
+ uTEST(MidimapParserTest::test_invalid);
}
- void test()
+ void test_basic()
{
ScopedFile scoped_file(
"<?xml version='1.0' encoding='UTF-8'?>\n" \
@@ -80,7 +82,47 @@ public:
uASSERT_EQUAL(std::string("Hihat_closed"), midimap[5].instrument_name);
}
- void invalid()
+ void test_curve()
+ {
+ ScopedFile scoped_file(
+ "<?xml version='1.0' encoding='UTF-8'?>\n" \
+ "<midimap>\n" \
+ " <map note=\"56\" instr=\"Hihat_closed\"/>\n" \
+ " <map note=\"40\" instr=\"Kick\">\n" \
+ " <curve in0=\"0.1\" out0=\"0.2\" in1=\"0.5\" out1=\"0.6\" in2=\"0.8\" out2=\"0.9\" invert=\"true\" shelf=\"false\"/>\n" \
+ " </map>\n" \
+ " <map note=\"41\" instr=\"Snare\">\n" \
+ " <curve/>\n" \
+ " </map>\n" \
+ "</midimap>");
+
+ MidiMapParser parser;
+ uASSERT(parser.parseFile(scoped_file.filename()));
+
+ const auto& midimap = parser.midimap;
+ uASSERT_EQUAL(3u, midimap.size());
+
+ uASSERT_EQUAL(56, midimap[0].note_id);
+ uASSERT(!midimap[0].maybe_curve_map);
+
+ uASSERT_EQUAL(40, midimap[1].note_id);
+ uASSERT(midimap[1].maybe_curve_map.get());
+ uASSERT_EQUAL(true, midimap[1].maybe_curve_map->getInvert());
+ uASSERT_EQUAL(false, midimap[1].maybe_curve_map->getShelf());
+ uASSERT_EQUAL(0.1, midimap[1].maybe_curve_map->getFixed0().in);
+ uASSERT_EQUAL(0.2, midimap[1].maybe_curve_map->getFixed0().out);
+ uASSERT_EQUAL(0.5, midimap[1].maybe_curve_map->getFixed1().in);
+ uASSERT_EQUAL(0.6, midimap[1].maybe_curve_map->getFixed1().out);
+ uASSERT_EQUAL(0.8, midimap[1].maybe_curve_map->getFixed2().in);
+ uASSERT_EQUAL(0.9, midimap[1].maybe_curve_map->getFixed2().out);
+
+ uASSERT_EQUAL(41, midimap[2].note_id);
+ CurveMap reference_map;
+ uASSERT(midimap[2].maybe_curve_map.get());
+ uASSERT(reference_map == *midimap[2].maybe_curve_map);
+ }
+
+ void test_invalid()
{
ScopedFile scoped_file(
"<?xml version='1.0' encoding='UTF-8'?>\n" \