fix: verification of const/var decls
missing cases of AidlConstantValue::Type caused crashes when verifying
const decls of AidlDefinedTypes.
Now we verify all types of const/var decls.
Bug: 175478675
Test: aidl_unittests
Change-Id: I6524032c227f6c40b895d80c0ab172a978081390
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 03b7d66..5079296 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -1038,6 +1038,17 @@
EXPECT_EQ(AidlError::BAD_TYPE, error);
}
+TEST_F(AidlTest, BoolConstantsEvaluatesToIntegers) {
+ io_delegate_.SetFileContents("a/Foo.aidl", "package a; parcelable Foo { const int y = true; }");
+ CaptureStderr();
+ auto options = Options::From("aidl --lang java -o out a/Foo.aidl");
+ EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ("", GetCapturedStderr());
+ string code;
+ EXPECT_TRUE(io_delegate_.GetWrittenContents("out/a/Foo.java", &code));
+ EXPECT_THAT(code, testing::HasSubstr("public static final int y = 1;"));
+}
+
TEST_P(AidlTest, FailOnManyDefinedTypes) {
AidlError error;
const string expected_stderr =