mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 08:46:45 +08:00
fix(test): replace C++17 structured bindings with C++14 compatible code
Problem: - Two test cases in test_buffer.cpp used structured bindings (auto [a, b]) - Structured bindings are a C++17 feature - Project requires C++14 compatibility Solution: - Replace 'auto [ptr, size] = buf.to_tuple()' with C++14 compatible code - Use std::get<N>() to extract tuple elements - Modified tests: ToTupleNonConst, ToTupleConst Changes: - Line 239: Use std::get<0/1>(tuple) instead of structured binding - Line 252: Use std::get<0/1>(tuple) instead of structured binding - Add explanatory comments for clarity This ensures the test suite compiles with C++14 standard.
This commit is contained in:
parent
c31ef988c1
commit
cf5738eb3a
@ -236,7 +236,10 @@ TEST_F(BufferTest, ToTupleNonConst) {
|
|||||||
|
|
||||||
buffer buf(data, 25, DestructorTracker::destructor);
|
buffer buf(data, 25, DestructorTracker::destructor);
|
||||||
|
|
||||||
auto [ptr, size] = buf.to_tuple();
|
// C++14 compatible: use std::get instead of structured binding
|
||||||
|
auto tuple = buf.to_tuple();
|
||||||
|
auto ptr = std::get<0>(tuple);
|
||||||
|
auto size = std::get<1>(tuple);
|
||||||
EXPECT_EQ(ptr, buf.data());
|
EXPECT_EQ(ptr, buf.data());
|
||||||
EXPECT_EQ(size, buf.size());
|
EXPECT_EQ(size, buf.size());
|
||||||
EXPECT_EQ(size, 25u);
|
EXPECT_EQ(size, 25u);
|
||||||
@ -249,7 +252,10 @@ TEST_F(BufferTest, ToTupleConst) {
|
|||||||
|
|
||||||
const buffer buf(data, 30, DestructorTracker::destructor);
|
const buffer buf(data, 30, DestructorTracker::destructor);
|
||||||
|
|
||||||
auto [ptr, size] = buf.to_tuple();
|
// C++14 compatible: use std::get instead of structured binding
|
||||||
|
auto tuple = buf.to_tuple();
|
||||||
|
auto ptr = std::get<0>(tuple);
|
||||||
|
auto size = std::get<1>(tuple);
|
||||||
EXPECT_EQ(ptr, buf.data());
|
EXPECT_EQ(ptr, buf.data());
|
||||||
EXPECT_EQ(size, buf.size());
|
EXPECT_EQ(size, buf.size());
|
||||||
EXPECT_EQ(size, 30u);
|
EXPECT_EQ(size, 30u);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user