本文整理汇总了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"));
}
示例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"})));
}
示例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"));
}
示例4: TEST
TEST(TestTimer, Construct) {
Timer timer;
timer.Start("a");
EXPECT_ANY_THROW(timer.End("b"));
timer.End("a");
timer.Display();
}
示例5: TEST
TEST(PathFinder, ThrowsExceptionWhenNotInitialized) {
// Arrange
PathFinder p;
// Act
// Assert
EXPECT_ANY_THROW(p.GetDistance(0));
}
示例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));
}
示例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);
}
示例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";
}
示例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));
}
示例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());
}
示例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);
}
示例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));
}
示例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()));
}