Tests: Fixed Issues And Made Prettier
Used the Second Dimension to make the output for tests easier to read and look at.
This commit is contained in:
parent
750f250545
commit
3f592696d6
|
@ -95,8 +95,6 @@ namespace dropout_dl {
|
||||||
std::string close_tag(">");
|
std::string close_tag(">");
|
||||||
std::string close_a("</a>");
|
std::string close_a("</a>");
|
||||||
|
|
||||||
int series_name_start = -1;
|
|
||||||
|
|
||||||
for (int i = 0; i < html_data.size(); i++) {
|
for (int i = 0; i < html_data.size(); i++) {
|
||||||
if (substr_is(html_data, i, series_title)) {
|
if (substr_is(html_data, i, series_title)) {
|
||||||
for (int j = i + series_title.size(); j < html_data.size(); j++) {
|
for (int j = i + series_title.size(); j < html_data.size(); j++) {
|
||||||
|
@ -104,18 +102,10 @@ namespace dropout_dl {
|
||||||
if (substr_is(html_data, j, open_a_tag)) {
|
if (substr_is(html_data, j, open_a_tag)) {
|
||||||
for (int k = j + open_a_tag.size(); k < html_data.size(); k++) {
|
for (int k = j + open_a_tag.size(); k < html_data.size(); k++) {
|
||||||
if (substr_is(html_data, k, close_tag)) {
|
if (substr_is(html_data, k, close_tag)) {
|
||||||
|
k++;
|
||||||
for (int l = 0; l < html_data.size() - k; l++) {
|
for (int l = 0; l < html_data.size() - k; l++) {
|
||||||
char c = html_data[k + l];
|
if (substr_is(html_data, k + l, close_a)) {
|
||||||
if (series_name_start == -1) {
|
return remove_leading_and_following_whitespace(html_data.substr(k, l));
|
||||||
if (html_data[k + l + 1] == '\n' || html_data[k + l + 1] == ' ' ||
|
|
||||||
html_data[k + l + 1] == '\t') {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
series_name_start = k + l + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (substr_is(html_data, k + l, close_a) || (series_name_start != -1 && html_data[k + l] == '\n')) {
|
|
||||||
return html_data.substr(series_name_start, l - (series_name_start - k));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,13 +126,13 @@ namespace dropout_dl {
|
||||||
if (substr_is(html_data, i, video_title)) {
|
if (substr_is(html_data, i, video_title)) {
|
||||||
for (int j = i; j < html_data.size(); j++) {
|
for (int j = i; j < html_data.size(); j++) {
|
||||||
if (substr_is(html_data, j, open_strong)) {
|
if (substr_is(html_data, j, open_strong)) {
|
||||||
title_start = j + 8;
|
title_start = j + open_strong.size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int j = 0; j < html_data.size() - title_start; j++) {
|
for (int j = 0; j < html_data.size() - title_start; j++) {
|
||||||
if (substr_is(html_data, title_start + j, close_strong)) {
|
if (substr_is(html_data, title_start + j, close_strong)) {
|
||||||
return html_data.substr(title_start, j);
|
return remove_leading_and_following_whitespace(html_data.substr(title_start, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace dropout_dl {
|
||||||
|
|
||||||
out.emplace_back("Earlier Episode Text Number Parsing", test_function, earlier_episode_text_test, earlier_episode_text_test_solution);
|
out.emplace_back("Earlier Episode Text Number Parsing", test_function, earlier_episode_text_test, earlier_episode_text_test_solution);
|
||||||
|
|
||||||
return {"Episode Name Parsing", out};
|
return {"Episode Number Parsing", out};
|
||||||
}
|
}
|
||||||
|
|
||||||
tests test_episode_series_name_parsing() {
|
tests test_episode_series_name_parsing() {
|
||||||
|
@ -171,7 +171,7 @@ namespace dropout_dl {
|
||||||
|
|
||||||
out.emplace_back("Html Character Code Episode Series Name Parsing", test_function, html_character_test, html_character_test_solution);
|
out.emplace_back("Html Character Code Episode Series Name Parsing", test_function, html_character_test, html_character_test_solution);
|
||||||
|
|
||||||
return {"Episode Name Parsing", out};
|
return {"Series Name Parsing", out};
|
||||||
}
|
}
|
||||||
|
|
||||||
tests test_episode_embedded_url_parsing() {
|
tests test_episode_embedded_url_parsing() {
|
||||||
|
@ -262,7 +262,7 @@ namespace dropout_dl {
|
||||||
|
|
||||||
out.emplace_back("No Valid Embedded URL Parsing", test_function, no_valid_URL_test, no_valid_URL_test_solution);
|
out.emplace_back("No Valid Embedded URL Parsing", test_function, no_valid_URL_test, no_valid_URL_test_solution);
|
||||||
|
|
||||||
return {"Episode Name Parsing", out};
|
return {"Embedded URL Parsing", out};
|
||||||
}
|
}
|
||||||
|
|
||||||
tests test_episode_config_url_parsing() {
|
tests test_episode_config_url_parsing() {
|
||||||
|
@ -281,7 +281,7 @@ namespace dropout_dl {
|
||||||
|
|
||||||
out.emplace_back("No Valid Config URL Parsing", test_function, no_valid_URL_test, no_valid_URL_test_solution);
|
out.emplace_back("No Valid Config URL Parsing", test_function, no_valid_URL_test, no_valid_URL_test_solution);
|
||||||
|
|
||||||
return {"Episode Name Parsing", out};
|
return {"Config URL Parsing", out};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
template<typename t>
|
template<typename t>
|
||||||
void dropout_dl::test<t>::display_result() {
|
void dropout_dl::test<t>::display_result() {
|
||||||
|
std::cout << "\t\t";
|
||||||
|
|
||||||
if (!this->success) {
|
if (!this->success) {
|
||||||
std::cout << RED << name << ": \"" << result << "\" =/= \"" << expected_result << '"' << RESET << std::endl;
|
std::cout << RED << name << ": \"" << result << "\" =/= \"" << expected_result << '"' << RESET << std::endl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,12 +18,22 @@ void dropout_dl::test<t>::display_result() {
|
||||||
|
|
||||||
void dropout_dl::tests::display() {
|
void dropout_dl::tests::display() {
|
||||||
|
|
||||||
if (!this->success) {
|
int success_count = 0;
|
||||||
std::cout << '\n' << TESTNAME << BOLDRED << name << RESET << std::endl;
|
|
||||||
} else {
|
for (auto& test : this->tests_vector) {
|
||||||
std::cout << '\n' << TESTNAME << BOLDGREEN << name << RESET << std::endl;
|
success_count += test.success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << '\t' << TESTNAME;
|
||||||
|
|
||||||
|
if (!this->success) {
|
||||||
|
std::cout << BOLDRED;
|
||||||
|
} else {
|
||||||
|
std::cout << BOLDGREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << name << " [" << success_count << "/" << this->tests_vector.size() << "]" << RESET << std::endl;
|
||||||
|
|
||||||
for (auto& test : tests_vector) {
|
for (auto& test : tests_vector) {
|
||||||
test.display_result();
|
test.display_result();
|
||||||
}
|
}
|
||||||
|
@ -33,40 +45,51 @@ int main() {
|
||||||
std::vector<dropout_dl::tests> episode_tests = test_episode();
|
std::vector<dropout_dl::tests> episode_tests = test_episode();
|
||||||
|
|
||||||
bool episode_tests_success = true;
|
bool episode_tests_success = true;
|
||||||
|
int episode_success_count = 0;
|
||||||
|
|
||||||
|
|
||||||
for (const auto& test : episode_tests) {
|
for (const auto& test : episode_tests) {
|
||||||
episode_tests_success &= test.success;
|
episode_tests_success &= test.success;
|
||||||
|
episode_success_count += test.success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (episode_tests_success) {
|
if (episode_tests_success) {
|
||||||
std::cout << TESTNAME << BOLDGREEN << episode_tests_name << std::endl;
|
std::cout << TESTNAME << BOLDGREEN << episode_tests_name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << TESTNAME << BOLDRED << episode_tests_name << std::endl;
|
std::cout << TESTNAME << BOLDRED << episode_tests_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << " [" << episode_success_count << "/" << episode_tests.size() << "]" << RESET << std::endl;
|
||||||
|
|
||||||
for (auto& test : episode_tests) {
|
for (auto& test : episode_tests) {
|
||||||
test.display();
|
test.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::cout << "\n\n";
|
std::cout << "\n";
|
||||||
|
|
||||||
|
|
||||||
std::string series_tests_name = "Series Tests";
|
std::string series_tests_name = "Series Tests";
|
||||||
std::vector<dropout_dl::tests> series_tests = test_series();
|
std::vector<dropout_dl::tests> series_tests = test_series();
|
||||||
|
|
||||||
bool series_tests_success = true;
|
bool series_tests_success = true;
|
||||||
for (const auto& test : episode_tests) {
|
int series_success_count = 0;
|
||||||
|
for (const auto& test : series_tests) {
|
||||||
series_tests_success &= test.success;
|
series_tests_success &= test.success;
|
||||||
|
series_success_count += test.success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (series_tests_success) {
|
if (series_tests_success) {
|
||||||
std::cout << TESTNAME << BOLDGREEN << series_tests_name << std::endl;
|
std::cout << TESTNAME << BOLDGREEN << series_tests_name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << TESTNAME << BOLDRED << series_tests_name << std::endl;
|
std::cout << TESTNAME << BOLDRED << series_tests_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << " [" << series_success_count << "/" << series_tests.size() << "]" << RESET << std::endl;
|
||||||
|
|
||||||
for (auto& test : series_tests) {
|
for (auto& test : series_tests) {
|
||||||
test.display();
|
test.display();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue