summaryrefslogtreecommitdiff
path: root/tests/auto/environment/tst_environment.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-10-19 11:10:58 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-11-17 13:19:06 +0100
commit0641ed0eaa40499af7cacaeda10d7b845a14aaf9 (patch)
treef8d0b52a751071403dad2fbf50b5f3a53d602ed4 /tests/auto/environment/tst_environment.cpp
parentfb47cfda115482351ef57092be58ba47b3276389 (diff)
downloadqt-creator-0641ed0eaa40499af7cacaeda10d7b845a14aaf9.tar.gz
change Environment::expandVariables() semantics
instead of being os-agnostic, interpret the os-native expansion style, so it is consistent with proper (shell) command lines. don't interpret quotes, as this function is meant for expanding isolated filepaths, where nobody would expect quoting. instead, use the windows style of simply not doing an expansion if a referenced variable is not found, which should be good enough - it's rather unlikely that something which happens to be an expansion of an existing variable is actually not meant to be one.
Diffstat (limited to 'tests/auto/environment/tst_environment.cpp')
-rw-r--r--tests/auto/environment/tst_environment.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/tests/auto/environment/tst_environment.cpp b/tests/auto/environment/tst_environment.cpp
new file mode 100644
index 0000000000..26d4b752b9
--- /dev/null
+++ b/tests/auto/environment/tst_environment.cpp
@@ -0,0 +1,107 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include <utils/environment.h>
+
+#include <QtTest/QtTest>
+
+using namespace Utils;
+
+class tst_Environment : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void environment_data();
+ void environment();
+
+private:
+ Environment env;
+};
+
+void tst_Environment::initTestCase()
+{
+ env.set("word", "hi");
+}
+
+void tst_Environment::environment_data()
+{
+ QTest::addColumn<QString>("in");
+ QTest::addColumn<QString>("out");
+
+ static const struct {
+ const char * const in;
+ const char * const out;
+ } vals[] = {
+#ifdef Q_OS_WIN
+ { "", "" },
+ { "hi", "hi" },
+ { "hi%", "hi%" },
+ { "hi% ho", "hi% ho" },
+ { "hi%here ho", "hi%here ho" },
+ { "hi%here%ho", "hi%here%ho" },
+ { "hi%word%", "hihi" },
+ { "hi%foo%word%", "hi%foohi" },
+ { "%word%word%ho", "hiword%ho" },
+ { "hi%word%x%word%ho", "hihixhiho" },
+ { "hi%word%xx%word%ho", "hihixxhiho" },
+ { "hi%word%%word%ho", "hihihiho" },
+#else
+ { "", "" },
+ { "hi", "hi" },
+ { "hi$", "hi$" },
+ { "hi${", "hi${" },
+ { "hi${word", "hi${word" },
+ { "hi${word}", "hihi" },
+ { "hi${word}ho", "hihiho" },
+ { "hi$wo", "hi$wo" },
+ { "hi$word", "hihi" },
+ { "hi$word ho", "hihi ho" },
+ { "$word", "hi" },
+ { "hi${word}$word", "hihihi" },
+#endif
+ };
+
+ for (unsigned i = 0; i < sizeof(vals)/sizeof(vals[0]); i++)
+ QTest::newRow(vals[i].in) << QString::fromLatin1(vals[i].in)
+ << QString::fromLatin1(vals[i].out);
+}
+
+void tst_Environment::environment()
+{
+ QFETCH(QString, in);
+ QFETCH(QString, out);
+
+ QCOMPARE(env.expandVariables(in), out);
+}
+
+QTEST_MAIN(tst_Environment)
+
+#include "tst_environment.moc"