From e8a3b1ffacb7b0ff42fd86fd532f7a2908c224e9 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 9 Jun 2018 14:15:43 +0200 Subject: Add drumkitparser test to dgxmlparser test. --- test/dgxmlparsertest.cc | 89 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/test/dgxmlparsertest.cc b/test/dgxmlparsertest.cc index 04d4372..3201d3e 100644 --- a/test/dgxmlparsertest.cc +++ b/test/dgxmlparsertest.cc @@ -34,6 +34,7 @@ class DGXmlParserTest { CPPUNIT_TEST_SUITE(DGXmlParserTest); CPPUNIT_TEST(instrumentParserTest); + CPPUNIT_TEST(drumkitParserTest); CPPUNIT_TEST_SUITE_END(); public: @@ -45,7 +46,6 @@ public: { } - //! This just creates some drumkit. void instrumentParserTest() { ScopedFile scoped_file( @@ -132,6 +132,93 @@ public: CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom"), dom.instrument_channels[2].name); CPPUNIT_ASSERT_EQUAL(main_state_t::unset, dom.instrument_channels[2].main); } + + void drumkitParserTest() + { + ScopedFile scoped_file( + "\n" \ + "\n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + ""); + + DrumkitDOM dom; + CPPUNIT_ASSERT(probeDrumkitFile(scoped_file.filename())); + CPPUNIT_ASSERT(parseDrumkitFile(scoped_file.filename(), dom)); + + CPPUNIT_ASSERT_EQUAL(std::string("CrocellKit"), dom.name); + CPPUNIT_ASSERT_EQUAL(std::string("my description"), dom.description); + CPPUNIT_ASSERT_EQUAL(48000.0, dom.samplerate); + CPPUNIT_ASSERT_EQUAL(std::size_t(2), dom.instruments.size()); + { + const auto& instr = dom.instruments[0]; + CPPUNIT_ASSERT_EQUAL(std::string("Snare1"), instr.name); + CPPUNIT_ASSERT_EQUAL(std::string("foo.wav"), instr.file); + CPPUNIT_ASSERT_EQUAL(std::string("somegroup"), instr.group); + CPPUNIT_ASSERT_EQUAL(std::size_t(4), instr.channel_map.size()); + + CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft-in"), instr.channel_map[0].in); + CPPUNIT_ASSERT_EQUAL(std::string("AmbRight-in"), instr.channel_map[1].in); + CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom-in"), instr.channel_map[2].in); + CPPUNIT_ASSERT_EQUAL(std::string("SnareTop-in"), instr.channel_map[3].in); + + CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft"), instr.channel_map[0].out); + CPPUNIT_ASSERT_EQUAL(std::string("AmbRight"), instr.channel_map[1].out); + CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom"), instr.channel_map[2].out); + CPPUNIT_ASSERT_EQUAL(std::string("SnareTop"), instr.channel_map[3].out); + + CPPUNIT_ASSERT_EQUAL(main_state_t::is_main, instr.channel_map[0].main); + CPPUNIT_ASSERT_EQUAL(main_state_t::is_main, instr.channel_map[1].main); + CPPUNIT_ASSERT_EQUAL(main_state_t::unset, instr.channel_map[2].main); + CPPUNIT_ASSERT_EQUAL(main_state_t::unset, instr.channel_map[3].main); + } + { + const auto& instr = dom.instruments[1]; + CPPUNIT_ASSERT_EQUAL(std::string("Snare2"), instr.name); + CPPUNIT_ASSERT_EQUAL(std::string("bar.wav"), instr.file); + CPPUNIT_ASSERT_EQUAL(std::string(""), instr.group); + CPPUNIT_ASSERT_EQUAL(std::size_t(4), instr.channel_map.size()); + + CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft2-in"), instr.channel_map[0].in); + CPPUNIT_ASSERT_EQUAL(std::string("AmbRight2-in"), instr.channel_map[1].in); + CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom2-in"), instr.channel_map[2].in); + CPPUNIT_ASSERT_EQUAL(std::string("SnareTop2-in"), instr.channel_map[3].in); + + CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft"), instr.channel_map[0].out); + CPPUNIT_ASSERT_EQUAL(std::string("AmbRight"), instr.channel_map[1].out); + CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom"), instr.channel_map[2].out); + CPPUNIT_ASSERT_EQUAL(std::string("SnareTop"), instr.channel_map[3].out); + + CPPUNIT_ASSERT_EQUAL(main_state_t::is_not_main, instr.channel_map[0].main); + CPPUNIT_ASSERT_EQUAL(main_state_t::is_not_main, instr.channel_map[1].main); + CPPUNIT_ASSERT_EQUAL(main_state_t::unset, instr.channel_map[2].main); + CPPUNIT_ASSERT_EQUAL(main_state_t::unset, instr.channel_map[3].main); + } + + CPPUNIT_ASSERT_EQUAL(std::size_t(4), dom.channels.size()); + CPPUNIT_ASSERT_EQUAL(std::string("AmbLeft"), dom.channels[0].name); + CPPUNIT_ASSERT_EQUAL(std::string("AmbRight"), dom.channels[1].name); + CPPUNIT_ASSERT_EQUAL(std::string("SnareBottom"), dom.channels[2].name); + CPPUNIT_ASSERT_EQUAL(std::string("SnareTop"), dom.channels[3].name); + } }; // Registers the fixture into the 'registry' -- cgit v1.2.3