Skip to content

Commit

Permalink
Test mixed-length UTF-8 iteration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtv committed Jan 27, 2019
1 parent 5e12316 commit 1efe59d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/unit/test_encodings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ void test_for_glyphs_utf8()
PQXX_CHECK_EQUAL(points.size(), 2u, "Wrong number of UTF-8 iterations.");
PQXX_CHECK_EQUAL(points[0], 2u, "UTF-8 iteration started off wrong.");
PQXX_CHECK_EQUAL(points[1], 2u, "ASCII iteration was inconsistent.");

// Greek lambda, ASCII plus sign, Old Persian Gu.
const std::string mix{"\xce\xbb+\xf0\x90\x8e\xa6"};
points.clear();

pqxx::internal::for_glyphs(
pqxx::internal::encoding_group::UTF8,
[&points](const char *gbegin, const char *gend){
points.push_back(gend - gbegin);
},
mix.c_str(),
mix.size());

PQXX_CHECK_EQUAL(points.size(), 3u, "Mixed UTF-8 iteration is broken.");
PQXX_CHECK_EQUAL(points[0], 2u, "Mixed UTF-8 iteration started off wrong.");
PQXX_CHECK_EQUAL(points[1], 1u, "Mixed UTF-8 iteration got ASCII wrong.");
PQXX_CHECK_EQUAL(points[2], 4u, "Mixed UTF-8 iteration got long char wrong.");
}


Expand Down

0 comments on commit 1efe59d

Please sign in to comment.