AAPT2: Respect format attribute of <item> tag
An <item> is a general tag that can override certain behavior. For
instance, this is allowed:
<item name="foo" type="integer" format="float">0.4</item>
Even though without the format attribute, this would be illegal.
Change-Id: I8133ce59e14719a70d7476a1464c3f564c435289
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index 84f67c6..2cc94d4 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -575,4 +575,14 @@
EXPECT_EQ(SymbolState::kUndefined, entry->symbolStatus.state);
}
+TEST_F(ResourceParserTest, ParseItemElementWithFormat) {
+ std::string input = R"EOF(<item name="foo" type="integer" format="float">0.3</item>)EOF";
+ ASSERT_TRUE(testParse(input));
+
+ BinaryPrimitive* val = test::getValue<BinaryPrimitive>(&mTable, u"@integer/foo");
+ ASSERT_NE(nullptr, val);
+
+ EXPECT_EQ(uint32_t(android::Res_value::TYPE_FLOAT), val->value.dataType);
+}
+
} // namespace aapt