diff --git a/include/sst/basic-blocks/mod-matrix/ModMatrix.h b/include/sst/basic-blocks/mod-matrix/ModMatrix.h index b74a8a3..cf38401 100644 --- a/include/sst/basic-blocks/mod-matrix/ModMatrix.h +++ b/include/sst/basic-blocks/mod-matrix/ModMatrix.h @@ -64,9 +64,21 @@ struct RoutingTable : details::CheckModMatrixConstraints std::optional target{std::nullopt}; std::optional curve{std::nullopt}; - float depth{0}; + float depth{0.f}; - std::optional extraPayload; + std::optional extraPayload{std::nullopt}; + + bool hasDefaultValues() const + { + auto res = active; + res = res && (depth == 0.f); + res = res && (!source.has_value()); + res = res && (!sourceVia.has_value()); + res = res && (!target.has_value()); + res = res && (!curve.has_value()); + res = res && (!extraPayload.has_value()); + return res; + } }; }; diff --git a/tests/mod_matrix_tests.cpp b/tests/mod_matrix_tests.cpp index d018a9e..31f9628 100644 --- a/tests/mod_matrix_tests.cpp +++ b/tests/mod_matrix_tests.cpp @@ -110,6 +110,47 @@ template <> struct std::hash } }; +TEST_CASE("Default Values Check Works", "[mod-matrix]") +{ + FixedMatrix m; + FixedMatrix::RoutingTable rt; + for (const auto &r : rt.routes) + { + assert(r.hasDefaultValues()); + } + + auto barS = Config::SourceIdentifier{Config::SourceIdentifier::SI::BAR, 2, 3}; + auto fooS = Config::SourceIdentifier{Config::SourceIdentifier::SI::FOO}; + + auto tg3T = Config::TargetIdentifier{3}; + auto tg3PT = Config::TargetIdentifier{3, 'facd'}; + + float barSVal{1.1}, fooSVal{2.3}; + m.bindSourceValue(barS, barSVal); + m.bindSourceValue(fooS, fooSVal); + + float t3V{0.2}, t3PV{0.3}; + m.bindTargetBaseValue(tg3T, t3V); + m.bindTargetBaseValue(tg3PT, t3PV); + + rt.updateRoutingAt(3, barS, tg3T, 0.5); + rt.updateRoutingAt(1, fooS, tg3PT, -0.5); + + int idx{0}; + for (const auto &r : rt.routes) + { + if (idx == 3 || idx == 1) + { + assert(!r.hasDefaultValues()); + } + else + { + assert(r.hasDefaultValues()); + } + idx++; + } +} + TEST_CASE("Configure and Bind", "[mod-matrix]") { FixedMatrix m;