summaryrefslogtreecommitdiffstats
path: root/sigscript
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-03-17 21:32:52 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-03-17 21:34:34 -0400
commit3f3822a2627f84ac77c1cbad02f2e13252e66cf9 (patch)
tree8adb9506b24084cb26f44a17096165624a53e6ff /sigscript
parent3f69c44f73a40bb0fbcf97dd61cf5a69f35b977f (diff)
downloadsigen-3f3822a2627f84ac77c1cbad02f2e13252e66cf9.tar.gz
sigen-3f3822a2627f84ac77c1cbad02f2e13252e66cf9.tar.xz
sigen-3f3822a2627f84ac77c1cbad02f2e13252e66cf9.zip
Fix up tests
Diffstat (limited to 'sigscript')
-rw-r--r--sigscript/test/CMakeLists.txt1
-rw-r--r--sigscript/test/TestConfig.cpp38
2 files changed, 34 insertions, 5 deletions
diff --git a/sigscript/test/CMakeLists.txt b/sigscript/test/CMakeLists.txt
index 4b5746cf..682e0005 100644
--- a/sigscript/test/CMakeLists.txt
+++ b/sigscript/test/CMakeLists.txt
@@ -1,4 +1,5 @@
set(libraries
+ sigcore
sigscript
)
diff --git a/sigscript/test/TestConfig.cpp b/sigscript/test/TestConfig.cpp
index 953b35a4..e63eb732 100644
--- a/sigscript/test/TestConfig.cpp
+++ b/sigscript/test/TestConfig.cpp
@@ -21,10 +21,14 @@
// Sigscript includes
#include <sigscript/Config.h>
+// Sigcore includes
+#include <sigcore/Fraction.h>
+
// Qt includes
#include <QtTest/QSignalSpy>
#include <QtTest/QTest>
+using namespace Sigcore;
using namespace Sigscript;
void TestConfig::initTestCase()
@@ -102,7 +106,7 @@ void TestConfig::testSetOptions()
QCOMPARE(m_config->setOptions("op3", ReadOnly), true);
QCOMPARE(m_config->setOptions("op4", Temporary), true);
- QCOMPARE(m_config->setOptions("op2", Hidden), false);
+ QCOMPARE(m_config->setOptions("op3", ReadOnly), false);
QCOMPARE(changeSpy.count(), 4);
}
@@ -118,12 +122,12 @@ void TestConfig::testOptions()
QCOMPARE(m_config->hasValue("op4"), true);
QCOMPARE(m_config->addValue("op1", 10), true);
- QCOMPARE(m_config->addValue("op2", 20), false);
+ QCOMPARE(m_config->addValue("op2", 20), true);
QCOMPARE(m_config->setValue("op3", 30), false);
QCOMPARE(m_config->value("op3").toInt(), 3);
- QCOMPARE(changeSpy.count(), 1);
+ QCOMPARE(changeSpy.count(), 2);
QCOMPARE(optChangeSpy.count(), 1);
}
@@ -155,10 +159,12 @@ void TestConfig::testUnsetOptions()
void TestConfig::testValueList()
{
+ m_config->setOptions("asdf", Hidden);
+
QStringList values = m_config->values(false);
qSort(values);
QStringList list;
- list << "bar" << "baz" << "op1" << "op3";
+ list << "bar" << "baz" << "op1" << "op2" << "op3";
QCOMPARE(values, list);
@@ -177,7 +183,7 @@ void TestConfig::testValueList()
values = subConfig->values(true);
qSort(values);
list.clear();
- list << "bar" << "blag" << "op1" << "op3";
+ list << "bar" << "blag" << "op1" << "op2" << "op3";
qSort(list);
QCOMPARE(values, list);
@@ -187,10 +193,32 @@ void TestConfig::testValueList()
void TestConfig::testOptionsRead()
{
+ QCOMPARE(m_config->options("asdf"), Hidden);
}
void TestConfig::testValueRead()
{
+ int intValue;
+ QString strValue;
+ Fraction fracValue(4, 5);
+
+ QCOMPARE(m_config->valueOfType("op3", &intValue), true);
+ QCOMPARE(m_config->valueOfType("op3", &strValue), true);
+ QCOMPARE(m_config->valueOfType("op3", &fracValue), false);
+
+ QCOMPARE(intValue, 30);
+ QCOMPARE(strValue, QString("30"));
+ QCOMPARE(fracValue, Fraction(4, 5));
+
+ Config* subConfig = new Config(m_config);
+
+ QCOMPARE(subConfig->setValue("op3", "foobar"), true);
+
+ QCOMPARE(subConfig->valueOfType("op3", &strValue), true);
+
+ QCOMPARE(strValue, QString("foobar"));
+
+ delete subConfig;
}
QTEST_APPLESS_MAIN(TestConfig)