mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-12 05:58:15 -04:00
Simple test for destructors
This commit is contained in:
parent
cfa5194984
commit
8b0dfd465f
@ -141,6 +141,28 @@ void test_reverse_iterator(){
|
||||
check(it == end, "Invalid reverse iterator");
|
||||
}
|
||||
|
||||
struct kiss {
|
||||
int* ref;
|
||||
kiss() {} // for vector
|
||||
kiss(int* ref) : ref(ref) {}
|
||||
~kiss(){
|
||||
++(*ref);
|
||||
}
|
||||
};
|
||||
|
||||
void test_destructor() {
|
||||
int counter = 0;
|
||||
|
||||
{
|
||||
std::vector<kiss> vec(3);
|
||||
vec.emplace_back(&counter);
|
||||
vec.emplace_back(&counter);
|
||||
vec.emplace_back(&counter);
|
||||
}
|
||||
|
||||
check(counter == 3, "Invalid destructors");
|
||||
}
|
||||
|
||||
} //end of anonymous namespace
|
||||
|
||||
void vector_tests(){
|
||||
@ -151,4 +173,5 @@ void vector_tests(){
|
||||
test_erase_remove_if();
|
||||
test_push_front();
|
||||
test_reverse_iterator();
|
||||
test_destructor();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user