Skip to content

Commit

Permalink
tests UTF-8 1, 2, 3, 4 byte characters
Browse files Browse the repository at this point in the history
Testing the INSERT and SELECT.
  • Loading branch information
silverqx committed Jul 26, 2024
1 parent ee78b3f commit 709ac28
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions tests/auto/functional/orm/query/querybuilder/tst_querybuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ private Q_SLOTS:

void whereBetween() const;

void insert_select_diacritic() const;
void insert_select_emoji() const;

/* where dates */
void whereDate_QDate();
void whereDate_QDateTime();
Expand Down Expand Up @@ -528,6 +531,90 @@ void tst_QueryBuilder::whereBetween() const
QCOMPARE(actualIds, expectedIds);
}

void tst_QueryBuilder::insert_select_diacritic() const
{
QFETCH_GLOBAL(QString, connection); // NOLINT(modernize-type-traits)

// UTF-8 1 and 2 byte characters
static const auto value = sl("ěščřžýáíéúůôäľĺŕéó");

{
auto builder = createQuery(connection);

auto query = builder->from("settings")
.insert({{"name", "t1"}, {"value", value}});

QVERIFY(query);
QCOMPARE(query->numRowsAffected(), 1);
QVERIFY(query->isActive());
QVERIFY(!query->isSelect());
QVERIFY(!query->isValid());
}

// Verify
{
auto builder = createQuery(connection);

auto query = builder->from("settings").first();

QVERIFY(query.isActive());
QVERIFY(query.isSelect());
QVERIFY(query.isValid());
QCOMPARE(query.value("value").toString(), value);
}

// Restore
{
auto builder = createQuery(connection);

builder->from("settings").truncate();

QCOMPARE(builder->from("settings").count(), 0);
}
}

void tst_QueryBuilder::insert_select_emoji() const
{
QFETCH_GLOBAL(QString, connection); // NOLINT(modernize-type-traits)

// UTF-8 3 and 4 byte characters
static const auto value = sl("🕺😁🤔😮😅👍😊❗🔥😭😞😔");

{
auto builder = createQuery(connection);

auto query = builder->from("settings")
.insert({{"name", "t1"}, {"value", value}});

QVERIFY(query);
QCOMPARE(query->numRowsAffected(), 1);
QVERIFY(query->isActive());
QVERIFY(!query->isSelect());
QVERIFY(!query->isValid());
}

// Verify
{
auto builder = createQuery(connection);

auto query = builder->from("settings").first();

QVERIFY(query.isActive());
QVERIFY(query.isSelect());
QVERIFY(query.isValid());
QCOMPARE(query.value("value").toString(), value);
}

// Restore
{
auto builder = createQuery(connection);

builder->from("settings").truncate();

QCOMPARE(builder->from("settings").count(), 0);
}
}

/* where dates */

void tst_QueryBuilder::whereDate_QDate()
Expand Down

0 comments on commit 709ac28

Please sign in to comment.