Remove flaky test and clarify documentation.
Resize doesn't set primitive types to zero.
Test: hidl's run_all_device_tests.sh
Change-Id: I0b7031bc563e3201815ac238ea5a375602393773
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index c8d8db9..ab16709 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -290,6 +290,7 @@
static_assert(hidl_vec<T>::kOffsetOfBuffer == 0, "wrong offset");
}
+ // Note, does not initialize primitive types.
hidl_vec(size_t size) : hidl_vec() { resize(size); }
hidl_vec(const hidl_vec<T> &other) : hidl_vec() {
@@ -448,6 +449,7 @@
return mBuffer[index];
}
+ // Does not initialize primitive types if new size > old size.
void resize(size_t size) {
if (size > UINT32_MAX) {
details::logAlwaysFatal("hidl_vec can't hold more than 2^32 elements.");
diff --git a/test_main.cpp b/test_main.cpp
index 89040c3..2811612 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -177,13 +177,11 @@
TEST_F(LibHidlTest, VecInitTest) {
using android::hardware::hidl_vec;
using std::vector;
- int32_t empty[3] = {0};
int32_t array[] = {5, 6, 7};
vector<int32_t> v(array, array + 3);
hidl_vec<int32_t> hv0(3); // size
- EXPECT_EQ(hv0.size(), 3ul);
- EXPECT_ARRAYEQ(hv0, empty, 3);
+ EXPECT_EQ(hv0.size(), 3ul); // cannot say anything about its contents
hidl_vec<int32_t> hv1 = v; // copy =
EXPECT_ARRAYEQ(hv1, array, 3);