本文整理汇总了C++中MyMoneySplit::replaceId方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySplit::replaceId方法的具体用法?C++ MyMoneySplit::replaceId怎么用?C++ MyMoneySplit::replaceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneySplit
的用法示例。
在下文中一共展示了MyMoneySplit::replaceId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testReplaceId
void MyMoneySplitTest::testReplaceId()
{
MyMoneySplit s;
bool changed;
s.setPayeeId("P000001");
s.setAccountId("A000076");
changed = s.replaceId("X0001", "Y00001");
QVERIFY(changed == false);
QVERIFY(s.payeeId() == "P000001");
QVERIFY(s.accountId() == "A000076");
changed = s.replaceId("P000002", "P000001");
QVERIFY(changed == true);
QVERIFY(s.payeeId() == "P000002");
QVERIFY(s.accountId() == "A000076");
changed = s.replaceId("A000079", "A000076");
QVERIFY(changed == true);
QVERIFY(s.payeeId() == "P000002");
QVERIFY(s.accountId() == "A000079");
QString ref_ok = QString(
"<!DOCTYPE TEST>\n"
"<SPLIT-CONTAINER>\n"
" <SPLIT payee=\"P000001\" reconciledate=\"\" shares=\"-125000/100\" action=\"Transfer\" bankid=\"A000076-2010-03-05-b6850c0-1\" number=\"\" reconcileflag=\"1\" memo=\"UMBUCHUNG\" value=\"-125000/100\" id=\"S0001\" account=\"A000076\" >\n"
" <KEYVALUEPAIRS>\n"
" <PAIR key=\"kmm-match-split\" value=\"S0002\" />\n"
" <PAIR key=\"kmm-matched-tx\" value=\"&lt;!DOCTYPE MATCH>\n"
" &lt;CONTAINER>\n"
" &lt;TRANSACTION postdate="2010-03-05" memo="UMBUCHUNG" id="" commodity="EUR" entrydate="2010-03-08" >\n"
" &lt;SPLITS>\n"
" &lt;SPLIT payee="P000010" reconciledate="" shares="125000/100" action="Transfer" bankid="" number="" reconcileflag="0" memo="UMBUCHUNG" value="125000/100" id="S0001" account="A000087" />\n"
" &lt;SPLIT payee="P000011" reconciledate="" shares="-125000/100" action="" bankid="A000076-2010-03-05-b6850c0-1" number="" reconcileflag="0" memo="UMBUCHUNG" value="-125000/100" id="S0002" account="A000076" />\n"
" &lt;/SPLITS>\n"
" &lt;KEYVALUEPAIRS>\n"
" &lt;PAIR key="Imported" value="true" />\n"
" &lt;/KEYVALUEPAIRS>\n"
" &lt;/TRANSACTION>\n"
" &lt;/CONTAINER>\n"
"\" />\n"
" <PAIR key=\"kmm-orig-memo\" value=\"\" />\n"
" </KEYVALUEPAIRS>\n"
" </SPLIT>\n"
"</SPLIT-CONTAINER>\n"
);
QDomDocument doc;
QDomElement node;
doc.setContent(ref_ok);
node = doc.documentElement().firstChild().toElement();
try {
s = MyMoneySplit(node);
QVERIFY(s.payeeId() == "P000001");
QVERIFY(s.replaceId("P2", "P1") == false);
QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P000010");
QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P000011");
QVERIFY(s.replaceId("P0010", "P000010") == true);
QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P0010");
QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P000011");
QVERIFY(s.replaceId("P0011", "P000011") == true);
QVERIFY(s.matchedTransaction().splits()[0].payeeId() == "P0010");
QVERIFY(s.matchedTransaction().splits()[1].payeeId() == "P0011");
} catch (const MyMoneyException &) {
QFAIL("Unexpected exception");
}
}