diff --git a/dynamic_programming/word_break.cpp b/dynamic_programming/word_break.cpp index 1ccdd05a4..0fbc7e733 100644 --- a/dynamic_programming/word_break.cpp +++ b/dynamic_programming/word_break.cpp @@ -148,6 +148,24 @@ bool wordBreak(const std::string &s, const std::vector &wordDict) { } // namespace word_break } // namespace dynamic_programming +/** + * @brief Test implementations + * @returns void + */ +static void test() { + // the complete string + const std::string s = "applepenapple"; + // the dictionary to be used + const std::vector wordDict = {"apple", "pen"}; + + assert(dynamic_programming::word_break::wordBreak(s, wordDict)); + + // should return true, as applepenapple can be segmented as apple + pen + + // apple + std::cout << dynamic_programming::word_break::wordBreak(s, wordDict) + << std::endl; + std::cout << "Test implementation passed!\n"; + } /** * @brief Main function * @returns 0 on exit