mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
CircularQueue: Ensure constructor does not construct any values
Problem: - There is no test which guarantees the CircularQueue does not construct any objects of the value type. The goal is to have uninitialized memory which can be used. Solution: - Add a test requiring that the constructor of the value type is never called.
This commit is contained in:
parent
c9ca897a45
commit
919fc7a814
1 changed files with 12 additions and 0 deletions
|
@ -75,4 +75,16 @@ TEST_CASE(complex_type_clear)
|
||||||
EXPECT_EQ(strings.size(), 0u);
|
EXPECT_EQ(strings.size(), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ConstructorCounter {
|
||||||
|
static unsigned s_num_constructor_calls;
|
||||||
|
ConstructorCounter() { ++s_num_constructor_calls; }
|
||||||
|
};
|
||||||
|
unsigned ConstructorCounter::s_num_constructor_calls = 0;
|
||||||
|
|
||||||
|
TEST_CASE(should_not_call_value_type_constructor_when_created)
|
||||||
|
{
|
||||||
|
CircularQueue<ConstructorCounter, 10> queue;
|
||||||
|
EXPECT_EQ(0u, ConstructorCounter::s_num_constructor_calls);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_MAIN(CircularQueue)
|
TEST_MAIN(CircularQueue)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue