diff --git a/source/simple/motion/melody.hpp b/source/simple/motion/melody.hpp index adeda2a643711bc55f45ef46cf87eb56339cdbba..635a805c6b7429f8f40dac846bc27a6ef0b3f093 100644 --- a/source/simple/motion/melody.hpp +++ b/source/simple/motion/melody.hpp @@ -18,7 +18,10 @@ class melody using result_t = multi_advance_result<duration>; melody() = default; - melody(Motions... motions) : movements{motions...} {} + melody(Motions... motions) : + movements{motions...}, + current_index{} + {} bool done() { @@ -119,7 +122,7 @@ class melody private: std::tuple<Motions...> movements; - size_t current_index = 0; + size_t current_index = sizeof...(Motions); template<typename F, size_t I = sizeof...(Motions) - 1> void for_all(F&& f) diff --git a/unit_tests/melody.cpp b/unit_tests/melody.cpp index 1a9eadeff0ff2e4d7fa52a603845f37f0d43dcba..88a764dbff108826f4e5afaa9ead7584a6bc0a72 100644 --- a/unit_tests/melody.cpp +++ b/unit_tests/melody.cpp @@ -104,9 +104,18 @@ void Advance() } +void EmptyIsDone() +{ + using movement = simple::motion::movement<std::chrono::milliseconds,float,float>; + using melody_t = melody<movement, movement>; + melody_t m; + assert(m.done()); +} + int main() { SharpTurn(); Advance(); + EmptyIsDone(); return 0; }