Add a test for array-supported types

The test shows that T[] is valid unless
- T is interface
- or, T is IBinder and backend is NDK/Rust.

Bug: 171932530
Test: aidl_unittests
Change-Id: I1689e5d94510ef7e039ec495fc62a4dc6d2e16f8
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 9fd7dc7..03b7d66 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -4388,6 +4388,41 @@
     {"rust_union", ""},
 };
 
+const std::map<std::string, std::string> kArraySupportExpectations = {
+    {"cpp_primitive", ""},
+    {"java_primitive", ""},
+    {"ndk_primitive", ""},
+    {"rust_primitive", ""},
+    {"cpp_String", ""},
+    {"java_String", ""},
+    {"ndk_String", ""},
+    {"rust_String", ""},
+    {"cpp_IBinder", ""},
+    {"java_IBinder", ""},
+    {"ndk_IBinder", "The ndk backend does not support array of IBinder"},
+    {"rust_IBinder", "The rust backend does not support array of IBinder"},
+    {"cpp_ParcelFileDescriptor", ""},
+    {"java_ParcelFileDescriptor", ""},
+    {"ndk_ParcelFileDescriptor", ""},
+    {"rust_ParcelFileDescriptor", ""},
+    {"cpp_interface", "Binder type cannot be an array"},
+    {"java_interface", "Binder type cannot be an array"},
+    {"ndk_interface", "Binder type cannot be an array"},
+    {"rust_interface", "Binder type cannot be an array"},
+    {"cpp_parcelable", ""},
+    {"java_parcelable", ""},
+    {"ndk_parcelable", ""},
+    {"rust_parcelable", ""},
+    {"cpp_enum", ""},
+    {"java_enum", ""},
+    {"ndk_enum", ""},
+    {"rust_enum", ""},
+    {"cpp_union", ""},
+    {"java_union", ""},
+    {"ndk_union", ""},
+    {"rust_union", ""},
+};
+
 class AidlTypeParamTest : public testing::TestWithParam<std::tuple<Options::Language, TypeParam>> {
  public:
   void Run(const std::string& generic_type_decl,
@@ -4432,5 +4467,9 @@
   Run("List<{}>", kListSupportExpectations);
 }
 
+TEST_P(AidlTypeParamTest, ArraySupportedTypes) {
+  Run("{}[]", kArraySupportExpectations);
+}
+
 }  // namespace aidl
 }  // namespace android