diff options
Diffstat (limited to 'test_main.cpp')
-rw-r--r-- | test_main.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test_main.cpp b/test_main.cpp index ea4dfd1..5c6c78e 100644 --- a/test_main.cpp +++ b/test_main.cpp @@ -175,6 +175,20 @@ TEST_F(LibHidlTest, StringTest) { EXPECT_FALSE(hs2 <= hs1); } +// empty string optimization should apply for any constructor +TEST_F(LibHidlTest, HidlStringEmptyLiteralAllocation) { + using android::hardware::hidl_string; + + hidl_string empty1; + hidl_string empty2(""); + hidl_string empty3("foo", 0); + hidl_string empty4((std::string())); + + EXPECT_EQ(empty1.c_str(), empty2.c_str()); + EXPECT_EQ(empty1.c_str(), empty3.c_str()); + EXPECT_EQ(empty1.c_str(), empty4.c_str()); +} + TEST_F(LibHidlTest, MemoryTest) { using android::hardware::hidl_memory; |