From 6cbf150a3391c87d895222b2b1ddc2046ccc8dad Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Mon, 8 Oct 2018 13:49:47 -0700 Subject: [test] Add unit test for TaggedString::trim() --- cmake/test-files.txt | 1 + test/text/tagged_string.test.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/text/tagged_string.test.cpp diff --git a/cmake/test-files.txt b/cmake/test-files.txt index 77a69bb450..a94004aa32 100644 --- a/cmake/test-files.txt +++ b/cmake/test-files.txt @@ -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 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 + +#include + +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!"); +} -- cgit v1.2.1