mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-27 06:54:25 +00:00
32af5266cf
- try to enforce the same style to all Qt related files - remove unneeded includes from the files - add missing Q_OBJECT, QT_BEGIN_NAMESPACE / QT_END_NAMESPACE - prepares for a pull-req to include Qt5 compatibility
63 lines
2.8 KiB
C++
63 lines
2.8 KiB
C++
#include "uritests.h"
|
|
#include "../guiutil.h"
|
|
#include "../walletmodel.h"
|
|
|
|
#include <QUrl>
|
|
|
|
void URITests::uriTests()
|
|
{
|
|
SendCoinsRecipient rv;
|
|
QUrl uri;
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.label == QString());
|
|
QVERIFY(rv.amount == 0);
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.label == QString("Wikipedia Example Address"));
|
|
QVERIFY(rv.amount == 0);
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.label == QString());
|
|
QVERIFY(rv.amount == 100000);
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.label == QString());
|
|
QVERIFY(rv.amount == 100100000);
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.amount == 10000000000LL);
|
|
QVERIFY(rv.label == QString("Wikipedia Example"));
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
QVERIFY(rv.label == QString());
|
|
|
|
// We currently don't implement the message parameter (ok, yea, we break spec...)
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
|
}
|