| 85 | } |
| 86 | |
| 87 | void ShapeTreeTest::TestInitValueConstructor(const Shape& shape, |
| 88 | int expected_num_nodes) { |
| 89 | ShapeTree<int> tree(shape, 42); |
| 90 | int num_nodes = 0; |
| 91 | tree.ForEachElement([&num_nodes](const ShapeIndex& /*index*/, int data) { |
| 92 | EXPECT_EQ(42, data); |
| 93 | ++num_nodes; |
| 94 | }); |
| 95 | EXPECT_EQ(expected_num_nodes, num_nodes); |
| 96 | |
| 97 | num_nodes = 0; |
| 98 | tree.ForEachMutableElement( |
| 99 | [&num_nodes](const ShapeIndex& /*index*/, int* data) { |
| 100 | EXPECT_EQ(42, *data); |
| 101 | *data = num_nodes; |
| 102 | ++num_nodes; |
| 103 | }); |
| 104 | EXPECT_EQ(expected_num_nodes, num_nodes); |
| 105 | |
| 106 | num_nodes = 0; |
| 107 | tree.ForEachElement([&num_nodes](const ShapeIndex& /*index*/, int data) { |
| 108 | EXPECT_EQ(num_nodes, data); |
| 109 | ++num_nodes; |
| 110 | }); |
| 111 | EXPECT_EQ(expected_num_nodes, num_nodes); |
| 112 | } |
| 113 | |
| 114 | TEST_F(ShapeTreeTest, InitValueConstructor) { |
| 115 | TestInitValueConstructor(array_shape_, 1); |
nothing calls this directly
no test coverage detected