[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdb] autotests/tools: Add autotest for all KDb::escapeIdentifier() variants
From: Jaroslaw Staniek <staniek () kde ! org>
Date: 2015-06-30 22:09:05
Message-ID: E1ZA3iD-00042Q-1U () scm ! kde ! org
[Download RAW message or body]
Git commit fa9bc21e022ee1a4f186ee6245811676ebd804c7 by Jaroslaw Staniek.
Committed on 30/06/2015 at 16:51.
Pushed by staniek into branch 'master'.
Add autotest for all KDb::escapeIdentifier() variants
M +29 -7 autotests/tools/IdentifierTest.cpp
M +2 -0 autotests/tools/IdentifierTest.h
http://commits.kde.org/kdb/fa9bc21e022ee1a4f186ee6245811676ebd804c7
diff --git a/autotests/tools/IdentifierTest.cpp b/autotests/tools/Identifie=
rTest.cpp
index b1228f2..a0b81bf 100644
--- a/autotests/tools/IdentifierTest.cpp
+++ b/autotests/tools/IdentifierTest.cpp
@@ -56,13 +56,13 @@ void IdentifierTest::testIsIdentifier_data()
QTest::addColumn<bool>("result");
QTest::newRow("empty") << "" << false;
QTest::newRow("empty") << QString() << false;
- QTest::newRow("empty") << "\0" << false;
- QTest::newRow("empty") << " " << false;
- QTest::newRow("empty") << "7" << false;
- QTest::newRow("empty") << "_" << true;
- QTest::newRow("empty") << "abc_2" << true;
- QTest::newRow("empty") << "Abc_2" << true;
- QTest::newRow("empty") << "_7" << true;
+ QTest::newRow("zero") << "\0" << false;
+ QTest::newRow("space") << " " << false;
+ QTest::newRow("number") << "7" << false;
+ QTest::newRow("underscore") << "_" << true;
+ QTest::newRow("alpha") << "abc_2" << true;
+ QTest::newRow("upper") << "Abc_2" << true;
+ QTest::newRow("upper2") << "_7" << true;
}
=
void IdentifierTest::testIsIdentifier()
@@ -72,6 +72,28 @@ void IdentifierTest::testIsIdentifier()
QCOMPARE(KDb::isIdentifier(string), result);
}
=
+void IdentifierTest::escapeIdentifier_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("result");
+ QTest::newRow("empty") << "" << QString();
+ QTest::newRow("empty") << QString() << QString();
+ QTest::newRow("\"") << "\"" << "\"\"";
+ QTest::newRow("\"-\"") << "\"-\"" << "\"\"-\"\"";
+ QTest::newRow("\t") << "\t" << "\t";
+ QTest::newRow("alpha") << "a b" << "a b";
+}
+
+void IdentifierTest::escapeIdentifier()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, result);
+ QCOMPARE(KDb::escapeIdentifier(string), result);
+ QCOMPARE(KDb::escapeIdentifier(string.toLatin1()), result.toLatin1());
+ QCOMPARE(KDb::escapeIdentifierAndAddQuotes(string), QString::fromLatin=
1("\"%1\"").arg(result));
+ QCOMPARE(KDb::escapeIdentifierAndAddQuotes(string.toLatin1()), '"' + r=
esult.toLatin1() + '"');
+}
+
void IdentifierTest::cleanupTestCase()
{
}
diff --git a/autotests/tools/IdentifierTest.h b/autotests/tools/IdentifierT=
est.h
index d7627d4..3a1f27c 100644
--- a/autotests/tools/IdentifierTest.h
+++ b/autotests/tools/IdentifierTest.h
@@ -31,6 +31,8 @@ private Q_SLOTS:
void testStringToIdentifier();
void testIsIdentifier_data();
void testIsIdentifier();
+ void escapeIdentifier_data();
+ void escapeIdentifier();
void cleanupTestCase();
};
=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic