AAPT2: Clean up tests a bit
Since the latest gtest has fixed support for
explicit bool operators, remvoe AAPT_ASSERT_* and AAPT_EXPECT_*.
Also switch to use NotNull() matchers, which are more legible.
Test: make aapt2_tests
Change-Id: Idce199ca9d567d70f7aae275fee15e04bb914c9e
diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp
index e2b37be..2a3c131 100644
--- a/tools/aapt2/ResourceTable_test.cpp
+++ b/tools/aapt2/ResourceTable_test.cpp
@@ -24,6 +24,8 @@
#include <ostream>
#include <string>
+using ::testing::NotNull;
+
namespace aapt {
TEST(ResourceTableTest, FailToAddResourceWithBadName) {
@@ -56,7 +58,7 @@
test::ValueBuilder<Id>().SetSource("test/path/file.xml", 23u).Build(),
test::GetDiagnostics()));
- ASSERT_NE(nullptr, test::GetValue<Id>(&table, "android:attr/id"));
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:attr/id"), NotNull());
}
TEST(ResourceTableTest, AddMultipleResources) {
@@ -88,11 +90,10 @@
.Build(),
test::GetDiagnostics()));
- ASSERT_NE(nullptr, test::GetValue<Id>(&table, "android:attr/layout_width"));
- ASSERT_NE(nullptr, test::GetValue<Id>(&table, "android:attr/id"));
- ASSERT_NE(nullptr, test::GetValue<Id>(&table, "android:string/ok"));
- ASSERT_NE(nullptr, test::GetValueForConfig<BinaryPrimitive>(
- &table, "android:string/ok", language_config));
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:attr/layout_width"), NotNull());
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:attr/id"), NotNull());
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:string/ok"), NotNull());
+ EXPECT_THAT(test::GetValueForConfig<BinaryPrimitive>(&table, "android:string/ok", language_config), NotNull());
}
TEST(ResourceTableTest, OverrideWeakResourceValue) {
@@ -103,7 +104,7 @@
util::make_unique<Attribute>(true), test::GetDiagnostics()));
Attribute* attr = test::GetValue<Attribute>(&table, "android:attr/foo");
- ASSERT_NE(nullptr, attr);
+ ASSERT_THAT(attr, NotNull());
EXPECT_TRUE(attr->IsWeak());
ASSERT_TRUE(table.AddResource(
@@ -111,7 +112,7 @@
util::make_unique<Attribute>(false), test::GetDiagnostics()));
attr = test::GetValue<Attribute>(&table, "android:attr/foo");
- ASSERT_NE(nullptr, attr);
+ ASSERT_THAT(attr, NotNull());
EXPECT_FALSE(attr->IsWeak());
}
@@ -127,16 +128,12 @@
util::make_unique<Id>(),
test::GetDiagnostics()));
- EXPECT_NE(nullptr, test::GetValueForConfigAndProduct<Id>(
- &table, "android:string/foo",
- test::ParseConfigOrDie("land"), "tablet"));
- EXPECT_NE(nullptr, test::GetValueForConfigAndProduct<Id>(
- &table, "android:string/foo",
- test::ParseConfigOrDie("land"), "phone"));
+ EXPECT_THAT(test::GetValueForConfigAndProduct<Id>(&table, "android:string/foo",test::ParseConfigOrDie("land"), "tablet"), NotNull());
+ EXPECT_THAT(test::GetValueForConfigAndProduct<Id>(&table, "android:string/foo",test::ParseConfigOrDie("land"), "phone"), NotNull());
Maybe<ResourceTable::SearchResult> sr =
table.FindResource(test::ParseNameOrDie("android:string/foo"));
- AAPT_ASSERT_TRUE(sr);
+ ASSERT_TRUE(sr);
std::vector<ResourceConfigValue*> values =
sr.value().entry->FindAllValues(test::ParseConfigOrDie("land"));
ASSERT_EQ(2u, values.size());