aboutsummaryrefslogtreecommitdiff
path: root/src/qt/test
diff options
context:
space:
mode:
authorMatt Corallo <matt@bluematt.me>2012-02-10 17:25:36 -0500
committerMatt Corallo <matt@bluematt.me>2012-02-10 17:47:00 -0500
commit245484679adbde8df6b0b01baa24393ea20a7aed (patch)
tree7a8a53463ab47ae2d6d8749212e8fc13199c3e05 /src/qt/test
parentcce89ead184c6b61a3361e598cc7553512730a72 (diff)
Add Bitcoin-Qt test suite with some bitcoin: URL Tests to start.
Diffstat (limited to 'src/qt/test')
-rw-r--r--src/qt/test/test_main.cpp11
-rw-r--r--src/qt/test/urltests.cpp68
-rw-r--r--src/qt/test/urltests.h15
3 files changed, 94 insertions, 0 deletions
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
new file mode 100644
index 0000000000..0a08eafa1e
--- /dev/null
+++ b/src/qt/test/test_main.cpp
@@ -0,0 +1,11 @@
+#include <QTest>
+#include <QObject>
+
+#include "urltests.h"
+
+// This is all you need to run all the tests
+int main(int argc, char *argv[])
+{
+ URLTests test1;
+ QTest::qExec(&test1);
+}
diff --git a/src/qt/test/urltests.cpp b/src/qt/test/urltests.cpp
new file mode 100644
index 0000000000..5ecc846203
--- /dev/null
+++ b/src/qt/test/urltests.cpp
@@ -0,0 +1,68 @@
+#include "urltests.h"
+#include "../guiutil.h"
+#include "../walletmodel.h"
+
+#include <QUrl>
+
+/*
+struct SendCoinsRecipient
+{
+ QString address;
+ QString label;
+ qint64 amount;
+};
+*/
+
+void URLTests::urlTests()
+{
+ SendCoinsRecipient rv;
+ QUrl url;
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
+ QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
+ QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.label == QString());
+ QVERIFY(rv.amount == 0);
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
+ QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.label == QString("Wikipedia Example Address"));
+ QVERIFY(rv.amount == 0);
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
+ QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.label == QString());
+ QVERIFY(rv.amount == 100000);
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
+ QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.label == QString());
+ QVERIFY(rv.amount == 100100000);
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
+ QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.amount == 10000000000);
+ QVERIFY(rv.label == QString("Wikipedia Example"));
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
+ QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.label == QString());
+ QVERIFY(rv.label == QString());
+
+ // We currently dont implement the message paramenter (ok, yea, we break spec...)
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
+ QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
+ QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+
+ url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
+ QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+}
diff --git a/src/qt/test/urltests.h b/src/qt/test/urltests.h
new file mode 100644
index 0000000000..393c511390
--- /dev/null
+++ b/src/qt/test/urltests.h
@@ -0,0 +1,15 @@
+#ifndef URLTESTS_H
+#define URLTESTS_H
+
+#include <QTest>
+#include <QObject>
+
+class URLTests : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void urlTests();
+};
+
+#endif // URLTESTS_H