AAPT2: Remove usage of u16string
For legacy reasons, we kept around the use of UTF-16 internally
in AAPT2. We don't need this and this CL removes all instances of
std::u16string and StringPiece16. The only places still needed
are when interacting with the ResTable APIs that only operate in
UTF16.
Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
diff --git a/tools/aapt2/NameMangler_test.cpp b/tools/aapt2/NameMangler_test.cpp
index 6103655..f624df2 100644
--- a/tools/aapt2/NameMangler_test.cpp
+++ b/tools/aapt2/NameMangler_test.cpp
@@ -15,31 +15,32 @@
*/
#include "NameMangler.h"
+#include "test/Test.h"
-#include <gtest/gtest.h>
#include <string>
namespace aapt {
TEST(NameManglerTest, MangleName) {
- std::u16string package = u"android.appcompat";
- std::u16string name = u"Platform.AppCompat";
+ std::string package = "android.appcompat";
+ std::string name = "Platform.AppCompat";
- NameMangler::mangle(package, &name);
- EXPECT_EQ(name, u"android.appcompat$Platform.AppCompat");
+ std::string mangledName = NameMangler::mangleEntry(package, name);
+ EXPECT_EQ(mangledName, "android.appcompat$Platform.AppCompat");
- std::u16string newPackage;
- ASSERT_TRUE(NameMangler::unmangle(&name, &newPackage));
- EXPECT_EQ(name, u"Platform.AppCompat");
- EXPECT_EQ(newPackage, u"android.appcompat");
+ std::string unmangledPackage;
+ std::string unmangledName = mangledName;
+ ASSERT_TRUE(NameMangler::unmangle(&unmangledName, &unmangledPackage));
+ EXPECT_EQ(unmangledName, "Platform.AppCompat");
+ EXPECT_EQ(unmangledPackage, "android.appcompat");
}
TEST(NameManglerTest, IgnoreUnmangledName) {
- std::u16string package;
- std::u16string name = u"foo_bar";
+ std::string package;
+ std::string name = "foo_bar";
EXPECT_FALSE(NameMangler::unmangle(&name, &package));
- EXPECT_EQ(name, u"foo_bar");
+ EXPECT_EQ(name, "foo_bar");
}
} // namespace aapt