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/test/Builders.h b/tools/aapt2/test/Builders.h
index f3da780..6b82076 100644
--- a/tools/aapt2/test/Builders.h
+++ b/tools/aapt2/test/Builders.h
@@ -212,8 +212,7 @@
}
StyleBuilder& AddItem(const android::StringPiece& str, std::unique_ptr<Item> value) {
- style_->entries.push_back(
- Style::Entry{Reference(ParseNameOrDie(str)), std::move(value)});
+ style_->entries.push_back(Style::Entry{Reference(ParseNameOrDie(str)), std::move(value)});
return *this;
}
@@ -224,7 +223,9 @@
return *this;
}
- std::unique_ptr<Style> Build() { return std::move(style_); }
+ std::unique_ptr<Style> Build() {
+ return std::move(style_);
+ }
private:
DISALLOW_COPY_AND_ASSIGN(StyleBuilder);
diff --git a/tools/aapt2/test/Common.h b/tools/aapt2/test/Common.h
index 0585148..bc8d274 100644
--- a/tools/aapt2/test/Common.h
+++ b/tools/aapt2/test/Common.h
@@ -34,15 +34,6 @@
#include "io/File.h"
#include "process/IResourceTableConsumer.h"
-//
-// GTEST 1.7 doesn't explicitly cast to bool, which causes explicit operators to
-// fail to compile.
-//
-#define AAPT_ASSERT_TRUE(v) ASSERT_TRUE(bool(v))
-#define AAPT_ASSERT_FALSE(v) ASSERT_FALSE(bool(v))
-#define AAPT_EXPECT_TRUE(v) EXPECT_TRUE(bool(v))
-#define AAPT_EXPECT_FALSE(v) EXPECT_FALSE(bool(v))
-
namespace aapt {
namespace test {
@@ -150,6 +141,10 @@
return arg.Equals(&a);
}
+MATCHER_P(StrValueEq, a, std::string(negation ? "isn't" : "is") + " equal to " + ::testing::PrintToString(a)) {
+ return *(arg.value) == a;
+}
+
} // namespace test
} // namespace aapt