gemini-code-assist[bot] commented on code in PR #219:
URL: https://github.com/apache/tvm-ffi/pull/219#discussion_r2486980742
##########
tests/cpp/test_tuple.cc:
##########
@@ -168,4 +168,12 @@ TEST(Tuple, ArrayIterForwardSingleElem) {
EXPECT_EQ(vec0[2].get<0>()->value, 2);
}
+TEST(Tuple, CPPStructuralBinding) {
+ Tuple<int, float, String> t(1, 2.0f, "hello");
+ auto [a, b, c] = t;
+ EXPECT_EQ(a, 1);
+ EXPECT_EQ(b, 2.0f);
+ EXPECT_EQ(c, "hello");
+}
+
} // namespace
Review Comment:

This test is great for verifying lvalue structured binding. To ensure full
coverage of the new functionality, please also add a test case for structured
binding on an rvalue tuple, which would exercise the new `get() &&` overload
and its move semantics.
For example, a new test case could look like this:
```cpp
TEST(Tuple, CPPStructuralBindingMove) {
Tuple<TInt, float, String> t(TInt(10), 2.0f, "hello");
// Ensure unique ownership for move to occur
EXPECT_EQ(t.use_count(), 1);
TInt old_tint = t.get<0>();
EXPECT_EQ(old_tint.use_count(), 2);
auto [a, b, c] = std::move(t);
EXPECT_EQ(a->value, 10);
EXPECT_EQ(b, 2.0f);
EXPECT_EQ(c, "hello");
// `a` should be the same object as `old_tint`
EXPECT_TRUE(a.same_as(old_tint));
// ref count should be 2 (a, old_tint)
EXPECT_EQ(a.use_count(), 2);
// After move, the elements in `t` should be null for object types.
TInt new_tint = t.get<0>();
EXPECT_FALSE(new_tint.defined());
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]