aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/unittest/smallstring-test.cpp
diff options
context:
space:
mode:
authorMarco Bubke <[email protected]>2017-01-31 16:16:40 +0100
committerMarco Bubke <[email protected]>2017-01-31 16:06:33 +0000
commit729c535376159f8a917e3d712d40a17d96909ecd (patch)
tree5283a276db72071cf1a7ace33cfd774f365b980c /tests/unit/unittest/smallstring-test.cpp
parent9b4afa01a120647ca696418108f0ef427c053375 (diff)
Utils: Add intializer_list constructor in SmallString
You can now write SmallString text = {"Oh ", women[4], " how much I miss you"}; if it can be casted to SmallStringView. Change-Id: I86b69ee8d735017cac4391e7c4e68355eb5f227b Reviewed-by: Tim Jenssen <[email protected]>
Diffstat (limited to 'tests/unit/unittest/smallstring-test.cpp')
-rw-r--r--tests/unit/unittest/smallstring-test.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/unittest/smallstring-test.cpp b/tests/unit/unittest/smallstring-test.cpp
index d846395c3ae..a0f2201bf7a 100644
--- a/tests/unit/unittest/smallstring-test.cpp
+++ b/tests/unit/unittest/smallstring-test.cpp
@@ -1186,3 +1186,45 @@ TEST(SmallString, ManipulateNonConstSubscriptOperator)
ASSERT_THAT(text, SmallString{"some qext"});
}
+
+TEST(SmallString, EmptyInitializerListContent)
+{
+ SmallString text = {};
+
+ ASSERT_THAT(text, SmallString());
+}
+
+TEST(SmallString, EmptyInitializerListSize)
+{
+ SmallString text = {};
+
+ ASSERT_THAT(text, SizeIs(0));
+}
+
+TEST(SmallString, EmptyInitializerListNullTerminated)
+{
+ auto end = SmallString{{}}[0];
+
+ ASSERT_THAT(end, '\0');
+}
+
+TEST(SmallString, InitializerListContent)
+{
+ SmallString text = {"some", " ", "text"};
+
+ ASSERT_THAT(text, SmallString("some text"));
+}
+
+TEST(SmallString, InitializerListSize)
+{
+ SmallString text = {"some", " ", "text"};
+
+ ASSERT_THAT(text, SizeIs(9));
+}
+
+TEST(SmallString, InitializerListNullTerminated)
+{
+ auto end = SmallString{"some", " ", "text"}[9];
+
+ ASSERT_THAT(end, '\0');
+}