neobytes/src/qt/test/uritests.cpp

63 lines
2.7 KiB
C++
Raw Normal View History

#include "uritests.h"
#include "guiutil.h"
#include "walletmodel.h"
#include <QUrl>
void URITests::uriTests()
{
SendCoinsRecipient rv;
QUrl uri;
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?req-dontexist="));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?dontexist="));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 0);
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?label=Some Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString("Some Example Address"));
QVERIFY(rv.amount == 0);
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=0.001"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100000);
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1.001"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100100000);
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=100&label=Some Example"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.amount == 10000000000LL);
2015-02-25 18:24:15 +01:00
QVERIFY(rv.label == QString("Some Example"));
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
2015-02-25 18:24:15 +01:00
QVERIFY(GUIUtil::parseBitcoinURI("darkcoin://XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?message=Some Example Address", &rv));
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
QVERIFY(rv.label == QString());
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?req-message=Some Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000&label=Some Example"));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
2015-02-25 18:24:15 +01:00
uri.setUrl(QString("darkcoin:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000.0&label=Some Example"));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
}