本文整理汇总了C++中GroupDef::getNumGroups方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupDef::getNumGroups方法的具体用法?C++ GroupDef::getNumGroups怎么用?C++ GroupDef::getNumGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupDef
的用法示例。
在下文中一共展示了GroupDef::getNumGroups方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testConstructors
void tstGroupDef::testConstructors()
{
printStartMsg("tstGroupDef::testConstructors");
// regular constructor
GroupDef g = GroupDef(4, 42);
CPPUNIT_ASSERT(g.getGroupSize() == 4);
CPPUNIT_ASSERT(g.getNumGroups() == 42);
// default argument: zero groups
g = GroupDef(8);
CPPUNIT_ASSERT(g.getGroupSize() == 8);
CPPUNIT_ASSERT(g.getNumGroups() == 0);
// invalid group size
CPPUNIT_ASSERT_THROW(GroupDef(2, 42), std::invalid_argument);
CPPUNIT_ASSERT_THROW(GroupDef(0, 42), std::invalid_argument);
CPPUNIT_ASSERT_THROW(GroupDef(-1, 42), std::invalid_argument);
// invalid number of groups
CPPUNIT_ASSERT_THROW(GroupDef(3, -1), std::invalid_argument);
// test the copy constructor
g = GroupDef(4, 44);
GroupDef gCopy = GroupDef(g);
g.setGroupSize(3); // modify original
g.setNumGroups(33); // modify original
CPPUNIT_ASSERT(g.getGroupSize() == 3); // test original
CPPUNIT_ASSERT(g.getNumGroups() == 33); // test original
CPPUNIT_ASSERT(gCopy.getGroupSize() == 4); // test copy
CPPUNIT_ASSERT(gCopy.getNumGroups() == 44); // test copy
printEndMsg();
}
示例2: toString
QString KO_Config::toString() const
{
QString result = "L16";
if (startLvl == SEMI) result = "S";
else if (startLvl == QUARTER) result = "Q";
else if (startLvl == FINAL) result = "F";
result += ";";
if (secondSurvives) result += "1";
else result += "0";
result += ";";
for (int i=0; i < grpDefs.count(); i++)
{
GroupDef g = grpDefs.at(i);
result += QString::number(g.getNumGroups()) + ";";
result += QString::number(g.getGroupSize()) + ";";
}
return result;
}
示例3: getNumGroups
int KO_Config::getNumGroups() const
{
int result = 0;
for (int i=0; i < grpDefs.count(); i++)
{
GroupDef g = grpDefs.at(i);
result += g.getNumGroups();
}
return result;
}
示例4: testSetters
void tstGroupDef::testSetters()
{
printStartMsg("tstGroupDef::testSetters");
// regular constructor
GroupDef g = GroupDef(4, 42);
CPPUNIT_ASSERT(g.getGroupSize() == 4);
CPPUNIT_ASSERT(g.getNumGroups() == 42);
// set group size
g.setGroupSize(3);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 42);
// illegal group size
CPPUNIT_ASSERT(g.setGroupSize(2) == false);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 42);
CPPUNIT_ASSERT(g.setGroupSize(0) == false);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 42);
CPPUNIT_ASSERT(g.setGroupSize(-1) == false);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 42);
// set number of groups
g.setNumGroups(0);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 0);
g.setNumGroups(23);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 23);
// illegal group numbers
CPPUNIT_ASSERT(g.setNumGroups(-1) == false);
CPPUNIT_ASSERT(g.getGroupSize() == 3);
CPPUNIT_ASSERT(g.getNumGroups() == 23);
printEndMsg();
}