Skip to content

Commit

Permalink
Merge pull request #107 from AnonymousProgrammerLandau/testFailesIfLe…
Browse files Browse the repository at this point in the history
…akingObjects

Make leaking tests count as failed.
  • Loading branch information
jeremyong committed Oct 7, 2015
2 parents 4e4a0c5 + e87f32a commit 244d288
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,25 @@ int ExecuteAll() {
for (auto it = tests.begin(); it != tests.end(); ++it) {
sel::State state{true};
const bool result = it->second(state);
int const leak_count = state.Size();
const bool leaked = leak_count != 0;
char progress_marker = 'E';
if (result) {
passing += 1;
std::cout << "." << std::flush;
if (!leaked) {
passing += 1;
progress_marker = '.';
} else {
failures.push_back(std::string{"Test \""} + it->first
+ "\" leaked " + std::to_string(leak_count) + " values");
progress_marker = 'l';
}
} else {
std::cout << "x" << std::flush;
progress_marker = 'x';
failures.push_back(std::string{"Test \""} +
it->first + "\" failed.");
}
int size = state.Size();
if (size != 0) {
failures.push_back(std::string{"Test \""} + it->first
+ "\" leaked " + std::to_string(size) + " values");
std::cout << progress_marker << std::flush;
if (leaked) {
std::cout << state << std::endl;
}
}
Expand Down

0 comments on commit 244d288

Please sign in to comment.