Allow hidl_vec = initializer list
Currently, a hidl vector can be constructed using an initializer list, but
it cannot be made equal to an initializer list.
Add the missing operator here to allow for simpler usage.
Test: atest libhidl_test
Bug: 117935272
Change-Id: Id21e9cafee754968a7300a3d7bc85481d32dcc3a
diff --git a/test_main.cpp b/test_main.cpp
index beb89d7..2b9f52c 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -280,6 +280,21 @@
EXPECT_TRUE(hv1 != hv3);
}
+TEST_F(LibHidlTest, VecEqInitializerTest) {
+ std::vector<int32_t> reference{5, 6, 7};
+ android::hardware::hidl_vec<int32_t> hv1{1, 2, 3};
+ hv1 = {5, 6, 7};
+ android::hardware::hidl_vec<int32_t> hv2;
+ hv2 = {5, 6, 7};
+ android::hardware::hidl_vec<int32_t> hv3;
+ hv3 = {5, 6, 8};
+
+ // use the == and != operator intentionally here
+ EXPECT_TRUE(hv1 == hv2);
+ EXPECT_TRUE(hv1 == reference);
+ EXPECT_TRUE(hv1 != hv3);
+}
+
TEST_F(LibHidlTest, VecRangeCtorTest) {
struct ConvertibleType {
int val;