Skip to content

Commit 1f4a2b0

Browse files
committed
Update on "add begin/end to ExecuTorch pytree::arr"
Allows use of range-for. Differential Revision: [D68166302](https://our.internmc.facebook.com/intern/diff/D68166302/) [ghstack-poisoned]
2 parents 4cedb6e + 751ff2e commit 1f4a2b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

extension/pytree/test/test_pytree.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,27 @@
1111
#include <gtest/gtest.h>
1212
#include <string>
1313

14+
using ::executorch::extension::pytree::arr;
1415
using ::executorch::extension::pytree::ContainerHandle;
1516
using ::executorch::extension::pytree::Key;
1617
using ::executorch::extension::pytree::Kind;
1718
using ::executorch::extension::pytree::unflatten;
1819

1920
using Leaf = int32_t;
2021

22+
TEST(PyTreeTest, ArrBasic) {
23+
arr<int> x(5);
24+
ASSERT_EQ(x.size(), 5);
25+
for (int ii = 0; ii < x.size(); ++ii) {
26+
x[ii] = 2 * ii;
27+
}
28+
int idx = 0;
29+
for (const auto item : x) {
30+
EXPECT_EQ(item, 2 * idx);
31+
++idx;
32+
}
33+
}
34+
2135
TEST(PyTreeTest, List) {
2236
Leaf items[2] = {11, 12};
2337
std::string spec = "L2#1#1($,$)";

0 commit comments

Comments
 (0)