Skip to content

Commit cf5738e

Browse files
committed
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.
1 parent c31ef98 commit cf5738e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/test_buffer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ TEST_F(BufferTest, ToTupleNonConst) {
236236

237237
buffer buf(data, 25, DestructorTracker::destructor);
238238

239-
auto [ptr, size] = buf.to_tuple();
239+
// C++14 compatible: use std::get instead of structured binding
240+
auto tuple = buf.to_tuple();
241+
auto ptr = std::get<0>(tuple);
242+
auto size = std::get<1>(tuple);
240243
EXPECT_EQ(ptr, buf.data());
241244
EXPECT_EQ(size, buf.size());
242245
EXPECT_EQ(size, 25u);
@@ -249,7 +252,10 @@ TEST_F(BufferTest, ToTupleConst) {
249252

250253
const buffer buf(data, 30, DestructorTracker::destructor);
251254

252-
auto [ptr, size] = buf.to_tuple();
255+
// C++14 compatible: use std::get instead of structured binding
256+
auto tuple = buf.to_tuple();
257+
auto ptr = std::get<0>(tuple);
258+
auto size = std::get<1>(tuple);
253259
EXPECT_EQ(ptr, buf.data());
254260
EXPECT_EQ(size, buf.size());
255261
EXPECT_EQ(size, 30u);

0 commit comments

Comments
 (0)