summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-10-08 13:49:47 -0700
committerChris Loer <chris.loer@mapbox.com>2018-10-15 13:15:46 -0700
commit6cbf150a3391c87d895222b2b1ddc2046ccc8dad (patch)
treed05c8345440355935fa18691bc571cbb5da4d035 /test
parent2c2241c50645a677ec1d45aa1895021244744869 (diff)
downloadqtlocation-mapboxgl-6cbf150a3391c87d895222b2b1ddc2046ccc8dad.tar.gz
[test] Add unit test for TaggedString::trim()
Diffstat (limited to 'test')
-rw-r--r--test/text/tagged_string.test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/text/tagged_string.test.cpp b/test/text/tagged_string.test.cpp
new file mode 100644
index 0000000000..3c58ccd94b
--- /dev/null
+++ b/test/text/tagged_string.test.cpp
@@ -0,0 +1,27 @@
+
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/text/tagged_string.hpp>
+
+using namespace mbgl;
+
+TEST(TaggedString, Trim) {
+ TaggedString basic(u" \t\ntrim that and not this \n\t", SectionOptions(1.0f, 0));
+ basic.trim();
+ EXPECT_EQ(basic.rawText(), u"trim that and not this");
+
+ TaggedString twoSections;
+ twoSections.addSection(u" \t\ntrim that", 1.5f, 1);
+ twoSections.addSection(u" and not this \n\t", 0.5f, 2);
+
+ twoSections.trim();
+ EXPECT_EQ(twoSections.rawText(), u"trim that and not this");
+
+ TaggedString empty(u"\n\t\v \r \t\n", SectionOptions(1.0f, 0));
+ empty.trim();
+ EXPECT_EQ(empty.rawText(), u"");
+
+ TaggedString noTrim(u"no trim!", SectionOptions(1.0f, 0));
+ noTrim.trim();
+ EXPECT_EQ(noTrim.rawText(), u"no trim!");
+}