本文整理汇总了C++中Match::hasPlayerPair2方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::hasPlayerPair2方法的具体用法?C++ Match::hasPlayerPair2怎么用?C++ Match::hasPlayerPair2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::hasPlayerPair2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testGetPairs
void tstMatch::testGetPairs()
{
printStartMsg("tstMatch::testGetGroup");
TournamentDB* db = getScenario04(true);
Tournament t(getSqliteFileName());
MatchMngr* mm = Tournament::getMatchMngr();
Category mx = Tournament::getCatMngr()->getCategoryById(5);
ERR e;
auto mg = mm->getMatchGroup(mx, 1, 1, &e);
CPPUNIT_ASSERT(e == OK);
CPPUNIT_ASSERT(mg != nullptr);
auto mgl = mg->getMatches();
CPPUNIT_ASSERT(mgl.count() == 1);
Match ma = mgl.at(0);
// test the getPair-functions
CPPUNIT_ASSERT(ma.hasPlayerPair1() == false);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == false);
CPPUNIT_ASSERT_THROW(ma.getPlayerPair1(), std::runtime_error);
CPPUNIT_ASSERT_THROW(ma.getPlayerPair2(), std::runtime_error);
// (artificially) assign one pair
PlayerPair pp1 = Tournament::getPlayerMngr()->getPlayerPair(1);
(*db)[TAB_MATCH][ma.getId()].update(MA_PAIR1_REF, pp1.getPairId());
// test again
CPPUNIT_ASSERT(ma.hasPlayerPair1() == true);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == false);
CPPUNIT_ASSERT(ma.getPlayerPair1().getPairId() == pp1.getPairId());
CPPUNIT_ASSERT_THROW(ma.getPlayerPair2(), std::runtime_error);
// (artificially) assign the second pair
PlayerPair pp2 = Tournament::getPlayerMngr()->getPlayerPair(2);
(*db)[TAB_MATCH][ma.getId()].update(MA_PAIR2_REF, pp2.getPairId());
// test again
CPPUNIT_ASSERT(ma.hasPlayerPair1() == true);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == true);
CPPUNIT_ASSERT(ma.getPlayerPair1().getPairId() == pp1.getPairId());
CPPUNIT_ASSERT(ma.getPlayerPair2().getPairId() == pp2.getPairId());
// remove the first one
(*db)[TAB_MATCH][ma.getId()].update(MA_PAIR1_REF, QVariant());
// test again
CPPUNIT_ASSERT(ma.hasPlayerPair1() == false);
CPPUNIT_ASSERT(ma.hasPlayerPair2() == true);
CPPUNIT_ASSERT_THROW(ma.getPlayerPair1(), std::runtime_error);
CPPUNIT_ASSERT(ma.getPlayerPair2().getPairId() == pp2.getPairId());
delete db;
printEndMsg();
}