diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp index ea06295..1c26343 100644 --- a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp @@ -56,6 +56,8 @@ private slots: void insert(); void emptyNull(); void toStringList(); + void keys(); + void insertEnv(); void caseSensitivity(); void systemEnvironment(); @@ -154,6 +156,58 @@ void tst_QProcessEnvironment::toStringList() QVERIFY(result.contains("HELLO=World")); } +void tst_QProcessEnvironment::keys() +{ + QProcessEnvironment e; + QVERIFY(e.isEmpty()); + QVERIFY(e.keys().isEmpty()); + + e.insert("FOO", "bar"); + QStringList result = e.keys(); + QCOMPARE(result.length(), 1); + QCOMPARE(result.at(0), QString("FOO")); + + e.clear(); + e.insert("BAZ", ""); + result = e.keys(); + QCOMPARE(result.at(0), QString("BAZ")); + + e.insert("FOO", "bar"); + e.insert("A", "bc"); + e.insert("HELLO", "World"); + result = e.keys(); + QCOMPARE(result.length(), 4); + + // order is not specified, so use contains() + QVERIFY(result.contains("FOO")); + QVERIFY(result.contains("BAZ")); + QVERIFY(result.contains("A")); + QVERIFY(result.contains("HELLO")); +} + +void tst_QProcessEnvironment::insertEnv() +{ + QProcessEnvironment e; + e.insert("FOO", "bar"); + e.insert("A", "bc"); + e.insert("Hello", "World"); + + QProcessEnvironment e2; + e2.insert("FOO2", "bar2"); + e2.insert("A2", "bc2"); + e2.insert("Hello", "Another World"); + + e.insert(e2); + QStringList keys = e.keys(); + QCOMPARE(keys.length(), 5); + + QCOMPARE(e.value("FOO"), QString("bar")); + QCOMPARE(e.value("A"), QString("bc")); + QCOMPARE(e.value("Hello"), QString("Another World")); + QCOMPARE(e.value("FOO2"), QString("bar2")); + QCOMPARE(e.value("A2"), QString("bc2")); +} + void tst_QProcessEnvironment::caseSensitivity() { QProcessEnvironment e; |