From 10b1ed2fa99dbe9fd858f12bb06ce9165ddd0b32 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 21 Feb 2017 13:17:41 +0100 Subject: [PATCH] add `debug` mode to generate expected result + add one more test --- test/unit/text/shaping.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/test/unit/text/shaping.cpp b/test/unit/text/shaping.cpp index 3cee600d9..32cb402c6 100644 --- a/test/unit/text/shaping.cpp +++ b/test/unit/text/shaping.cpp @@ -7,7 +7,7 @@ namespace { void test_shaping( mapnik::font_set const& fontset, mapnik::face_manager& fm, - std::vector> const& expected, char const* str) + std::vector> const& expected, char const* str, bool debug = false) { mapnik::transcoder tr("utf8"); std::map width_map; @@ -30,11 +30,19 @@ void test_shaping( mapnik::font_set const& fontset, mapnik::face_manager& fm, std::size_t index = 0; for (auto const& g : line) { - unsigned glyph_index, char_index; - CHECK(index < expected.size()); - std::tie(glyph_index, char_index) = expected[index++]; - REQUIRE(glyph_index == g.glyph_index); - REQUIRE(char_index == g.char_index); + if (debug) + { + if (index++ > 0) std::cerr << ","; + std::cerr << "{" << g.glyph_index << ", " << g.char_index << "}"; + } + else + { + unsigned glyph_index, char_index; + CHECK(index < expected.size()); + std::tie(glyph_index, char_index) = expected[index++]; + REQUIRE(glyph_index == g.glyph_index); + REQUIRE(char_index == g.char_index); + } } } } @@ -76,4 +84,11 @@ TEST_CASE("shaping") test_shaping(fontset, fm, expected, "abc (普兰镇)"); } + { + std::vector> expected = + {{68, 0}, {69, 1}, {70, 2}, {3, 3}, {11, 4}, {68, 5}, {69, 6}, {70, 7}, {12, 8}}; + test_shaping(fontset, fm, expected, "abc (abc)"); + } + + }