Minor cleanup

This commit is contained in:
Victor Zverovich
2025-08-16 07:42:37 -07:00
parent e9ddc97b9a
commit 7ffc3ca15b
3 changed files with 35 additions and 52 deletions

View File

@@ -307,7 +307,7 @@ TEST(memory_buffer_test, ctor) {
EXPECT_EQ(123u, buffer.capacity());
}
using std_allocator = allocator_ref<std::allocator<char>, true>;
using std_allocator = allocator_ref<std::allocator<char>>;
TEST(memory_buffer_test, move_ctor_inline_buffer) {
auto check_move_buffer =
@@ -351,15 +351,15 @@ TEST(memory_buffer_test, move_ctor_dynamic_buffer) {
EXPECT_GT(buffer2.capacity(), 4u);
}
using std_allocator_n = allocator_ref<std::allocator<char>, false>;
using std_allocator_noprop = allocator_ref<std::allocator<char>, false>;
TEST(memory_buffer_test, move_ctor_inline_buffer_non_propagating) {
auto check_move_buffer =
[](const char* str,
basic_memory_buffer<char, 5, std_allocator_n>& buffer) {
basic_memory_buffer<char, 5, std_allocator_noprop>& buffer) {
std::allocator<char>* original_alloc_ptr = buffer.get_allocator().get();
const char* original_data_ptr = &buffer[0];
basic_memory_buffer<char, 5, std_allocator_n> buffer2(
basic_memory_buffer<char, 5, std_allocator_noprop> buffer2(
std::move(buffer));
const char* new_data_ptr = &buffer2[0];
EXPECT_NE(original_data_ptr, new_data_ptr);
@@ -373,8 +373,8 @@ TEST(memory_buffer_test, move_ctor_inline_buffer_non_propagating) {
EXPECT_NE(original_alloc_ptr, buffer2.get_allocator().get());
};
auto alloc = std::allocator<char>();
basic_memory_buffer<char, 5, std_allocator_n> buffer(
(std_allocator_n(&alloc)));
basic_memory_buffer<char, 5, std_allocator_noprop> buffer(
(std_allocator_noprop(&alloc)));
const char test[] = "test";
buffer.append(string_view(test, 4));
check_move_buffer("test", buffer);
@@ -384,15 +384,15 @@ TEST(memory_buffer_test, move_ctor_inline_buffer_non_propagating) {
TEST(memory_buffer_test, move_ctor_dynamic_buffer_non_propagating) {
auto alloc = std::allocator<char>();
basic_memory_buffer<char, 4, std_allocator_n> buffer(
(std_allocator_n(&alloc)));
basic_memory_buffer<char, 4, std_allocator_noprop> buffer(
(std_allocator_noprop(&alloc)));
const char test[] = "test";
buffer.append(test, test + 4);
const char* inline_buffer_ptr = &buffer[0];
buffer.push_back('a');
EXPECT_NE(&buffer[0], inline_buffer_ptr);
std::allocator<char>* original_alloc_ptr = buffer.get_allocator().get();
basic_memory_buffer<char, 4, std_allocator_n> buffer2;
basic_memory_buffer<char, 4, std_allocator_noprop> buffer2;
buffer2 = std::move(buffer);
EXPECT_EQ(std::string(&buffer2[0], buffer2.size()), "testa");
EXPECT_GT(buffer2.capacity(), 4u);