当前位置: 首页>>代码示例>>C++>>正文


C++ GroupDef::setNumGroups方法代码示例

本文整理汇总了C++中GroupDef::setNumGroups方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupDef::setNumGroups方法的具体用法?C++ GroupDef::setNumGroups怎么用?C++ GroupDef::setNumGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GroupDef的用法示例。


在下文中一共展示了GroupDef::setNumGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
开发者ID:Foorgol,项目名称:QTournament,代码行数:34,代码来源:tstGroupDef.cpp

示例2: 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();
}
开发者ID:Foorgol,项目名称:QTournament,代码行数:40,代码来源:tstGroupDef.cpp


注:本文中的GroupDef::setNumGroups方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。