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


C++ EXPECT_ANY_THROW函数代码示例

本文整理汇总了C++中EXPECT_ANY_THROW函数的典型用法代码示例。如果您正苦于以下问题:C++ EXPECT_ANY_THROW函数的具体用法?C++ EXPECT_ANY_THROW怎么用?C++ EXPECT_ANY_THROW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了EXPECT_ANY_THROW函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

TEST(TestStrand, TypeErasedCall)
{
  boost::shared_ptr<MyActor> obj(new MyActor);
  qi::AnyObject aobj(obj);

  EXPECT_EQ(42, aobj.async<int>("val").value());
  EXPECT_TRUE(aobj.async<int>("thrw").hasError());
  EXPECT_TRUE(aobj.async<int>("fail").hasError());

  EXPECT_EQ(42, aobj.call<int>("val"));
  EXPECT_ANY_THROW(aobj.call<int>("thrw"));
  EXPECT_ANY_THROW(aobj.call<int>("fail"));
}
开发者ID:dmerejkowsky,项目名称:libqi,代码行数:13,代码来源:test_strand.cpp

示例2: TEST_F

TEST_F(InstanceTest, String_invalid_constructions) {
    EXPECT_ANY_THROW(StringInstance("42"));
    EXPECT_ANY_THROW(StringInstance("create:", std::vector<std::string>()));
    EXPECT_ANY_THROW(StringInstance("createIfNotExists:", std::vector<std::string>()));
    EXPECT_ANY_THROW(StringInstance("create:withValue:", std::vector<std::string>({"str"})));
    EXPECT_ANY_THROW(StringInstance("create:withValue:", std::vector<std::string>({"str", "42"})));
    EXPECT_ANY_THROW(StringInstance("create:withValue:", std::vector<std::string>({"\"knuckleball\"", "str"})));
    EXPECT_ANY_THROW(StringInstance("createIfNotExists:withValue:", std::vector<std::string>({"str"})));
    EXPECT_ANY_THROW(StringInstance("createIfNotExists:withValue:", std::vector<std::string>({"str", "42"})));
    EXPECT_ANY_THROW(StringInstance("createIfNotExists:withValue:", std::vector<std::string>({"\"knuckleball\"", "str"})));
}
开发者ID:bryongloden,项目名称:knuckleball,代码行数:11,代码来源:instance_test.cpp

示例3: TEST

TEST(TStr, InsStr) {
	TStr Str = "abcda";
	TStr Empty = "";

	Str.InsStr(2, "xk");
	EXPECT_EQ(Str, "abxkcda");
	Str.InsStr(2, "");
	EXPECT_EQ(Str, "abxkcda");
	Str.InsStr(0, "f");
	EXPECT_EQ(Str, "fabxkcda");
	Str.InsStr(8, "f");
	EXPECT_EQ(Str, "fabxkcdaf");
	dup2(2, 1); // redirect stdout to stderr (Assert emits a printf to stdout)
	EXPECT_ANY_THROW(Str.InsStr(100, "kek"));
	EXPECT_ANY_THROW(Str.InsStr(-100, "kek"));
}
开发者ID:gitter-badger,项目名称:qminer,代码行数:16,代码来源:test-TStr.cpp

示例4: TEST

TEST(TestTimer, Construct) {
    Timer timer;
    timer.Start("a");
    EXPECT_ANY_THROW(timer.End("b"));
    timer.End("a");
    timer.Display();
}
开发者ID:ReiMatsuzaki,项目名称:opt_cbf,代码行数:7,代码来源:utest.cpp

示例5: TEST

TEST(PathFinder, ThrowsExceptionWhenNotInitialized) {
    // Arrange
    PathFinder p;
    // Act
    // Assert
    EXPECT_ANY_THROW(p.GetDistance(0));
}
开发者ID:Animan2010,项目名称:devtools-course-practice,代码行数:7,代码来源:test_path_finder.cpp

示例6: TEST

TEST(QST, TestConstructWithWrongSpaceDimension) {
    Matrix4cd matr;
    matr(0,0) = matr(3,0) = matr(0,3) = matr(3,3) = 0.5;
    
    HilbertSpace space(5);
    EXPECT_ANY_THROW(QuantumState state(matr, space));
}
开发者ID:narolez571,项目名称:QuantEmul,代码行数:7,代码来源:quantum_state_test.cpp

示例7: TEST

TEST(SharedValueTest, ctorNulls)
{
    EXPECT_NO_THROW(Value v(0));
    EXPECT_NO_THROW(Value v(0.0));
    EXPECT_NO_THROW(Value v(0.0f));
    EXPECT_NO_THROW(Value v('\0'));
    EXPECT_NO_THROW(Value v(false));
    EXPECT_NO_THROW(Value v(NULL));
    EXPECT_NO_THROW(Value v(nullptr));
    EXPECT_NO_THROW(Value v(Value::Null));

    Value v0(0);
    EXPECT_EQ(v0.type(), typeid(int));
    Value v0dot0(0.0);
    EXPECT_EQ(v0dot0.type(), typeid(float));
    Value v0s('\0');
    EXPECT_EQ(v0s.type(), typeid(int));
    Value vfalse(false);
    EXPECT_EQ(vfalse.type(), typeid(bool));
    Value vNULL(NULL);
    EXPECT_EQ(vNULL.type(), typeid(NULL));
    Value vValueNull(Value::Null);
    EXPECT_EQ(vValueNull.type(), typeid(Value::Null));

    EXPECT_NO_THROW(vValueNull = "Hello"); // not locked
    EXPECT_EQ(vValueNull.type(), typeid(const char*)); // now locked
    EXPECT_ANY_THROW(vValueNull = 1);
}
开发者ID:aasfalcon,项目名称:wexplorer,代码行数:28,代码来源:value_test.cpp

示例8: TEST_F

TEST_F( AppTest, SetupTest ) 
{
	// The following tests should all fail
	EXPECT_EQ( mApp->getCounter(), 0 ) << "Not initialized (should cause access violation error)\n";
	EXPECT_ANY_THROW( mApp->setup() ) << "This should be reported because there is no exception thrown\n";
	EXPECT_GT( mApp->getCounter(), 0 ) << "This should be 0\n";
}
开发者ID:BanTheRewind,项目名称:Cinder-GTest,代码行数:7,代码来源:AppTest.cpp

示例9: TEST

TEST(PathFinder, Throws_Exception_With_Start_Index_Out_Of_Range) {
    // Arrange
    PathFinder pathFinder;
    int** graph = new int*;
    *graph = new int(0);
    // Act & Assert
    EXPECT_ANY_THROW(pathFinder.SetGraph(graph, 1, 5));
}
开发者ID:Lenferd,项目名称:devtools-course-practice,代码行数:8,代码来源:test_path_finder.cpp

示例10: TEST_F

TEST_F(TesteFila, LimpaFilaElementoComplexo){
	for(int i = 0; i < 50; i++){
		Objeto obj(i*4);
		filaobj.inclui(obj);
	}
	filaobj.inicializaFila(); // LimparFila, não sei pq se chama assim
	EXPECT_ANY_THROW(filaobj.getUltimo());
}
开发者ID:idnilson,项目名称:UFSC-data-structures,代码行数:8,代码来源:teste_fila.cpp

示例11: TEST_F

TEST_F(TesteArvoreBinaria, RemoverFilhoDireita) {
	arv->inserir(8, arv);
	arv->inserir(9, arv);
	NoBinario<int>* root = arv->remover(arv, 8);
	EXPECT_ANY_THROW(*(arv->busca(8, arv)));
	arv->emOrdem(arv);
	NoBinario<int>* elemento = arv->getElementos();
	ASSERT_EQ(*(elemento->getDado()), 9);
}
开发者ID:idnilson,项目名称:UFSC-data-structures,代码行数:9,代码来源:teste_arvorebinaria.cpp

示例12: TEST_F

TEST_F(TestApplication, can_parse_command_line_unexpected_empty) {
    // Arrange
    constexpr int argc = 1;
    constexpr const char* argv[argc] = {
        "somepath_to_binary"
    };

    // Act & Assert
    EXPECT_ANY_THROW(parseCommandLine(argc, argv));
}
开发者ID:dabelyaeva,项目名称:devtools-course-practice,代码行数:10,代码来源:test_application.cpp

示例13: TEST

TEST(QiSession, testClose)
{
  qi::Session session;

  qi::Session sd;

  qi::Future<void> f = sd.listenStandalone("tcp://127.0.0.1:0");
  f.wait(3000);
  ASSERT_TRUE(!f.hasError());

  f = session.connect(sd.endpoints()[0]);
  f.wait(3000);
  ASSERT_TRUE(!f.hasError());

  qi::DynamicObjectBuilder ob;
  ob.advertiseMethod("reply", &reply);
  qi::AnyObject obj(ob.object());

  f = session.listen("tcp://127.0.0.1:0");
  f.wait(3000);
  ASSERT_TRUE(!f.hasError());

  // Wait for service id, otherwise register is asynchronous.
  qi::Future<unsigned int> idx = session.registerService("serviceTest", obj);
  ASSERT_FALSE(idx.hasError());

  qi::AnyObject object = session.service("serviceTest");
  EXPECT_TRUE(object);


  session.close();
  EXPECT_FALSE(session.isConnected());

  EXPECT_ANY_THROW(session.services().value());

  f = session.connect(sd.endpoints()[0]);
  f.wait(3000);
  if (f.hasError())
    qiLogError() << f.error();
  ASSERT_TRUE(!f.hasError());

  EXPECT_ANY_THROW(session.unregisterService(idx.value()));
}
开发者ID:cgestes,项目名称:libqi,代码行数:43,代码来源:test_session.cpp


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