-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9511b6d
commit 3627ac4
Showing
5 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "MidiChannel.h" | ||
#include "MidiMessage.h" | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
|
||
namespace Catch { | ||
template<> | ||
struct StringMaker<std::vector<uint8_t>> { | ||
static std::string convert(const std::vector<uint8_t>& vec) { | ||
std::ostringstream oss; | ||
oss << "["; | ||
for (size_t i=0; i<vec.size(); i++) { | ||
if (i>0) { oss << ", "; } | ||
oss << (int)vec[i]; | ||
} | ||
oss << "]"; | ||
return oss.str(); | ||
} | ||
}; | ||
|
||
template<> | ||
struct StringMaker<MidiMessage<uint32_t, uint32_t>> { | ||
static std::string convert(const MidiMessage<uint32_t, uint32_t>& e) { | ||
std::ostringstream oss; | ||
oss << "{ t:" << e.time << ", s:" << e.size << ", d:" << StringMaker<std::vector<uint8_t>>::convert(e.data) << " }"; | ||
return oss.str(); | ||
} | ||
}; | ||
|
||
template<> | ||
struct StringMaker<std::vector<MidiMessage<uint32_t, uint32_t>>> { | ||
static std::string convert(const std::vector<MidiMessage<uint32_t, uint32_t>>& vec) { | ||
std::ostringstream oss; | ||
oss << "[\n"; | ||
for (auto &e : vec) { | ||
oss << " " << StringMaker<MidiMessage<uint32_t, uint32_t>>::convert(e) << "\n"; | ||
} | ||
oss << "]"; | ||
return oss.str(); | ||
} | ||
}; | ||
} | ||
|
||
TEST_CASE("MidiChannel - Indifinite size", "[MidiChannel]") { | ||
using Msg = MidiMessage<uint32_t, uint32_t>; | ||
using Storage = MidiStorage<uint32_t, uint32_t>; | ||
using Channel = MidiChannel<uint32_t, uint32_t>; | ||
using Contents = Channel::Contents; | ||
|
||
auto c = shoop_make_shared<MidiChannel<uint32_t, uint32_t>>(1, ChannelMode_Direct); | ||
|
||
const std::vector<Msg> data = { | ||
Msg(0, 3, {0, 1, 2}), | ||
Msg(1, 3, {3, 4, 5}), | ||
Msg(10, 1, {10}) | ||
}; | ||
const Contents contents = { data, {} }; | ||
|
||
c->set_contents(contents, 1000, false); | ||
CHECK(c->retrieve_contents(false).recorded_msgs == data); | ||
}; |