Skip to content

Commit 17a70d4

Browse files
committed
Remove tests when destroyed
1 parent 0bd5267 commit 17a70d4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

provides/include/testing_v1/test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class test_base_t {
1818

1919
protected:
2020
test_base_t();
21-
~test_base_t() = default;
21+
~test_base_t();
2222
};
2323

2424
} // namespace testing_v1

provides/library/test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "testing_v1/test.hpp"
22

3+
#include <algorithm>
34
#include <cstdio>
45
#include <cstdlib>
56
#include <tuple>
@@ -33,6 +34,15 @@ testing_v1::test_base_t::test_base_t() {
3334
test_private::tests().push_back(this);
3435
}
3536

37+
testing_v1::test_base_t::~test_base_t() {
38+
auto &tests = test_private::tests();
39+
auto it = std::find(tests.rbegin(), tests.rend(), this);
40+
if (it != tests.rend()) {
41+
std::swap(*it, tests.back());
42+
tests.pop_back();
43+
}
44+
}
45+
3646
int main() {
3747
testing_v1::test_private::run_all();
3848
return 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy