// // Created by moss on 9/30/22. // #include "episode_tests.h" namespace dropout_dl { tests test_episode_name_parsing() { std::vector> out; std::string (*test_function)(const std::string&) = episode::get_episode_name; std::string base_test_solution = "Base Test Title"; std::string base_test = "

\n" " " + base_test_solution + "\n" "

"; out.emplace_back("Basic Episode Name Parsing", test_function, base_test, base_test_solution); std::string multiple_header_test_solution = "Multi Header Test Title"; std::string multiple_header_test = "

\n" "Header without class or strong\n" "

\n" "

\n" "Header with incorrect classes" "

\n" "

\n" "Header with strong" "

\n" "

\n" " " + multiple_header_test_solution + "\n" "

\n" "

\n" " Valid Header and Strong After Correct Title \n" "

"; out.emplace_back("Multiple Header Episode Name Parsing", test_function, multiple_header_test, multiple_header_test_solution); std::string no_valid_header_test_solution = "ERROR"; std::string no_valid_header_test = "

\n" "Header without class or Strong\n" "

\n" "

\n" "Header with incorrect classes" "

\n" "

\n" "Header with strong" "

\n"; out.emplace_back("No Valid Header Episode Name Parsing", test_function, no_valid_header_test, no_valid_header_test_solution); std::string html_character_test_solution = "'&;"; std::string html_character_test = "

\n" " '&;\n" "

"; out.emplace_back("Html Character Code Episode Name Parsing", test_function, html_character_test, html_character_test_solution); return {"Episode Name Parsing", out}; } tests test_episode_number_parsing() { std::vector> out; std::string (*test_function)(const std::string&) = episode::get_episode_number; std::string base_test_solution = "1"; std::string base_test = "\n" " Season 1, Episode 1\n" ""; out.emplace_back("Basic Episode Number Parsing", test_function, base_test, base_test_solution); std::string multiple_link_test_solution = "1"; std::string multiple_link_test = "\n" "asjdhgaorihg\n" "\n" "\n" " Season 1, Episode 1\n" "\n" "\n" " Season 1, Episode 2\n"; out.emplace_back("Multiple Link Episode Number Parsing", test_function, multiple_link_test, multiple_link_test_solution); std::string no_valid_number_test_solution = "-1"; std::string no_valid_number_test = "\n" "816\n" "\n" "\n" "157" "\n" "\n" "Episode" "\n"; out.emplace_back("No Valid Episode Number Parsing", test_function, no_valid_number_test, no_valid_number_test_solution); std::string earlier_episode_text_test_solution = "15"; std::string earlier_episode_text_test = "

\n" " Episode Wrong\n" "

\n" "\n" " Season 1, Episode 15\n" ""; out.emplace_back("Earlier Episode Text Number Parsing", test_function, earlier_episode_text_test, earlier_episode_text_test_solution); return {"Episode Number Parsing", out}; } tests test_episode_series_name_parsing() { std::vector> out; std::string (*test_function)(const std::string&) = episode::get_series_name; std::string base_test_solution = "Base Test Title"; std::string base_test = "

\n" " \n" " Base Test Title\n" " \n" "

"; out.emplace_back("Basic Episode Series Name Parsing", test_function, base_test, base_test_solution); std::string multiple_header_test_solution = "Multi Header Test Title"; std::string multiple_header_test = "

\n" "Header without class or link\n" "

\n" "

\n" "Header with incorrect classes" "

\n" "

\n" "Header with strong" "

\n" "

\n" " " + multiple_header_test_solution + "\n" "

\n" "

\n" " Valid Header and Link After Correct Title \n" "

"; out.emplace_back("Multiple Header Episode Series Name Parsing", test_function, multiple_header_test, multiple_header_test_solution); std::string no_valid_header_test_solution = "ERROR"; std::string no_valid_header_test = "

\n" "Header without class or link\n" "

\n" "

\n" "Header with incorrect classes" "

\n" "

\n" "Header with strong" "

\n"; out.emplace_back("No Valid Header Episode Series Name Parsing", test_function, no_valid_header_test, no_valid_header_test_solution); std::string html_character_test_solution = "'&;"; std::string html_character_test = "

\n" " '&;\n" "

"; out.emplace_back("Html Character Code Episode Series Name Parsing", test_function, html_character_test, html_character_test_solution); return {"Series Name Parsing", out}; } tests test_episode_embedded_url_parsing() { std::vector> out; std::string (*test_function)(const std::string&) = episode::get_embed_url; std::string base_test_solution = "Base Test URL"; std::string base_test = " window.VHX.config = {\n" " embed_url: \"" + base_test_solution + "\"\n" " };"; out.emplace_back("Basic Episode Embedded URL Parsing", test_function, base_test, base_test_solution); std::string multiple_script_test_solution = "Multi Header Test Title"; std::string multiple_script_test = " " "" "" "" "" "" ""; out.emplace_back("Multiple Script Embedded URL Parsing", test_function, multiple_script_test, multiple_script_test_solution); std::string no_valid_URL_test_solution = ""; std::string no_valid_URL_test = " "; out.emplace_back("No Valid Embedded URL Parsing", test_function, no_valid_URL_test, no_valid_URL_test_solution); return {"Embedded URL Parsing", out}; } tests test_episode_config_url_parsing() { std::vector> out; std::string (*test_function)(const std::string&) = episode::get_config_url; std::string base_test_solution = "Base Test URL"; std::string base_test = R"(window.OTTData = {"config_url":")" + base_test_solution + "\"};"; out.emplace_back("Basic Episode Config URL Parsing", test_function, base_test, base_test_solution); std::string no_valid_URL_test_solution = ""; std::string no_valid_URL_test = R"(window.OTTData = {"api_data":{"api_host":"","api_token":"","user_auth_token":{"auth_user_token":"","embed_referrer_host":""}},"buy_button":{"label":null,"url":null},"collection":{"id":null},"product":{"id":null},"":{"label":"","url":""},"site":{"id":null,"subdomain":"","twitter_name":""},"video":{"duration":null,"id":null,"is_trailer":"","title":"","is_live_video":false,"live_event_id":null},"google_cast_app_id":"","hide_chrome":null,"initial_time":null,"js_api_enabled":null,"locale":"","show_share_actions":null,"user":{"id":,"email":""},"analytics_url":""})"; out.emplace_back("No Valid Config URL Parsing", test_function, no_valid_URL_test, no_valid_URL_test_solution); return {"Config URL Parsing", out}; } } std::vector test_episode() { std::vector testss; testss.push_back(dropout_dl::test_episode_name_parsing()); testss.push_back(dropout_dl::test_episode_number_parsing()); testss.push_back(dropout_dl::test_episode_series_name_parsing()); testss.push_back(dropout_dl::test_episode_embedded_url_parsing()); testss.push_back(dropout_dl::test_episode_config_url_parsing()); return testss; }