[test] Add unit test for TaggedString::trim()

This commit is contained in:
Chris Loer
2018-10-08 13:49:47 -07:00
committed by Chris Loer
parent 2c2241c506
commit 6cbf150a33
2 changed files with 28 additions and 0 deletions

View File

@@ -115,6 +115,7 @@ test/text/glyph_pbf.test.cpp
test/text/language_tag.test.cpp
test/text/local_glyph_rasterizer.test.cpp
test/text/quads.test.cpp
test/text/tagged_string.test.cpp
# tile
test/tile/custom_geometry_tile.test.cpp

View File

@@ -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!");
}