* @brief Tests for tryCatch function
*/
-#include <common/exceptions/TryCatch.h>
-#include <common/exceptions/Exception.h>
-
#include <gmock/gmock.h>
#include <gtest/gtest.h>
};
};
+template<typename T, typename... Args>
+void testException(const std::string &expectedMessage, int expectedError, Args&&... args)
+{
+ // Note: because Cynara exceptions' destructors are marked as virtual, the compiler
+ // generates deleting destructors for these classes. Naturally, under normal circumstances
+ // exceptions are always allocated on the stack so these destructors won't ever be called
+ // thus decreasing our test coverage. Therefore explicit testing is performed here by using
+ // unique pointers.
+ using ::testing::StartsWith;
+
+ std::unique_ptr<T> e = std::make_unique<T>(std::forward<Args>(args)...);
+ ASSERT_THAT(e->what(), StartsWith(expectedMessage));
+
+ int ret = CYNARA_API_SUCCESS;
+ auto throwFun = [&]() { throw *e; return ret; };
+
+ ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
+ ASSERT_EQ(ret, expectedError);
+}
+
} // namespace anonymous
TEST(TryCatch, forcedUnwindNegative)
TEST(TryCatch, accessDeniedExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::AccessDeniedException e(SOME_ERROR);
- ASSERT_THAT(e.what(), StartsWith("Access denied from: " + SOME_ERROR));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_PERMISSION_DENIED);
+ testException<Cynara::AccessDeniedException>(
+ "Access denied from: " + SOME_ERROR,
+ CYNARA_API_PERMISSION_DENIED,
+ SOME_ERROR);
}
TEST(TryCatch, bucketDeserializationExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::BucketDeserializationException e(SOME_BUCKET);
- ASSERT_THAT(e.what(), StartsWith("Could not deserialize bucket " + SOME_BUCKET));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::BucketDeserializationException>(
+ "Could not deserialize bucket " + SOME_BUCKET,
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_BUCKET);
}
TEST(TryCatch, bucketNotExistsExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::BucketNotExistsException e(SOME_BUCKET);
- ASSERT_THAT(e.what(), StartsWith("Bucket " + SOME_BUCKET + " does not exist"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::BucketNotExistsException>(
+ "Bucket " + SOME_BUCKET + " does not exist",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_BUCKET);
}
TEST(TryCatch, bucketRecordCorruptionExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::BucketRecordCorruptedException e(SOME_LINE);
- ASSERT_THAT(e.what(), StartsWith("Bucket record corrupted at line: <" + SOME_LINE + ">"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::BucketRecordCorruptedException>(
+ "Bucket record corrupted at line: <" + SOME_LINE + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_LINE);
}
TEST(TryCatch, bucketSerializationExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::BucketSerializationException e(SOME_BUCKET);
- ASSERT_THAT(e.what(), StartsWith("Could not serialize bucket " + SOME_BUCKET));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::BucketSerializationException>(
+ "Could not serialize bucket " + SOME_BUCKET,
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_BUCKET);
}
TEST(TryCatch, cannotCreateFileExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::CannotCreateFileException e(SOME_FILE);
- ASSERT_THAT(e.what(), StartsWith("File " + SOME_FILE + " cannot be created"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::CannotCreateFileException>(
+ "File " + SOME_FILE + " cannot be created",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_FILE);
}
TEST(TryCatch, checksumRecordCorruptedExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::ChecksumRecordCorruptedException e(SOME_LINE);
- ASSERT_THAT(e.what(), StartsWith("Checksum record corrupted at line: <" + SOME_LINE + ">"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::ChecksumRecordCorruptedException>(
+ "Checksum record corrupted at line: <" + SOME_LINE + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_LINE);
}
TEST(TryCatch, contextErrorExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::ContextErrorException e;
- ASSERT_THAT(e.what(), StartsWith("ContextErrorException"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::ContextErrorException>(
+ "ContextErrorException",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, databaseBusyExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::DatabaseBusyException e;
- ASSERT_THAT(e.what(), StartsWith("Database busy"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DatabaseBusyException>(
+ "Database busy",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, databaseCorruptedExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::DatabaseCorruptedException e;
- ASSERT_THAT(e.what(), StartsWith("DatabaseCorruptedException"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DatabaseCorruptedException>(
+ "DatabaseCorruptedException",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, databaseReadExceptionNegative)
{
- using ::testing::StartsWith;
const std::string SOME_OP = "some operation";
- Cynara::DatabaseReadException e(SOME_FILE, SOME_OP);
- ASSERT_THAT(e.what(),
- StartsWith("Loading the database from the file <" + SOME_FILE
- + "> failed during " + SOME_OP));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DatabaseReadException>(
+ "Loading the database from the file <" + SOME_FILE + "> failed during " + SOME_OP,
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_FILE, SOME_OP);
}
TEST(TryCatch, databaseWriteExceptionNegative)
{
- using ::testing::StartsWith;
const std::string SOME_OP = "some operation";
- Cynara::DatabaseWriteException e(SOME_FILE, SOME_OP);
- ASSERT_THAT(e.what(),
- StartsWith("Saving the database to file <" + SOME_FILE
- + "> failed during " + SOME_OP));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DatabaseWriteException>(
+ "Saving the database to file <" + SOME_FILE + "> failed during " + SOME_OP,
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_FILE, SOME_OP);
}
TEST(TryCatch, defaultBucketDeletionExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::DefaultBucketDeletionException e;
- ASSERT_THAT(e.what(), StartsWith("DefaultBucketDeletionException"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DefaultBucketDeletionException>(
+ "DefaultBucketDeletionException",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, defaultBucketSetNoneExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::DefaultBucketSetNoneException e;
- ASSERT_THAT(e.what(), StartsWith("DefaultBucketSetNoneException"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DefaultBucketSetNoneException>(
+ "DefaultBucketSetNoneException",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, descriptorNotExistsExceptionNegative)
{
- using ::testing::StartsWith;
const int SOME_DSCR = 42;
- Cynara::DescriptorNotExistsException e(SOME_DSCR);
- ASSERT_THAT(e.what(), StartsWith("trying access not existing descriptor ["
- + std::to_string(SOME_DSCR) + "]"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::DescriptorNotExistsException>(
+ "trying access not existing descriptor [" + std::to_string(SOME_DSCR) + "]",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_DSCR);
}
TEST(TryCatch, fileLockAcquiringExceptionNegative)
{
- using ::testing::StartsWith;
const int SOME_ERRNO = 42;
const std::string SOME_ERRNO_STR = strerror(SOME_ERRNO);
- Cynara::FileLockAcquiringException e(SOME_ERRNO);
-
- ASSERT_THAT(e.what(),
- StartsWith("File lock acquiring error [" + std::to_string(SOME_ERRNO) + "]"
- + " <" + SOME_ERRNO_STR + ">"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::FileLockAcquiringException>(
+ "File lock acquiring error [" + std::to_string(SOME_ERRNO) + "]" +
+ " <" + SOME_ERRNO_STR + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_ERRNO);
}
TEST(TryCatch, fileNotFoundExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::FileNotFoundException e(SOME_FILE);
- ASSERT_THAT(e.what(),
- StartsWith("File " + SOME_FILE + " not found or corrupted badly"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::FileNotFoundException>(
+ "File " + SOME_FILE + " not found or corrupted badly",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_FILE);
}
TEST(TryCatch, initExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::InitException e;
- ASSERT_THAT(e.what(), StartsWith("InitException"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::InitException>(
+ "InitException",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, invalidBucketIdExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::InvalidBucketIdException e(SOME_BUCKET);
- ASSERT_THAT(e.what(),
- StartsWith("Bucket ID " + SOME_BUCKET + " contains forbidden characters"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::InvalidBucketIdException>(
+ "Bucket ID " + SOME_BUCKET + " contains forbidden characters",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_BUCKET);
}
TEST(TryCatch, invalidProtocolExceptionNegative)
};
for (auto& typeToString : INVALID_PROTOCOL_EXCEPTION_TYPE_TO_STRING) {
- Cynara::InvalidProtocolException e(typeToString.first);
- ASSERT_THAT(e.what(), StartsWith(typeToString.second));
+ std::unique_ptr<Cynara::InvalidProtocolException> e =
+ std::make_unique<Cynara::InvalidProtocolException>(typeToString.first);
+ ASSERT_THAT(e->what(), StartsWith(typeToString.second));
}
int ret = CYNARA_API_SUCCESS;
TEST(TryCatch, noMemoryExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::NoMemoryException e(SOME_ERROR);
- ASSERT_THAT(e.what(), StartsWith("NoMemoryException with message <" + SOME_ERROR + ">"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_OUT_OF_MEMORY);
+ testException<Cynara::NoMemoryException>(
+ "NoMemoryException with message <" + SOME_ERROR + ">",
+ CYNARA_API_OUT_OF_MEMORY,
+ SOME_ERROR);
}
TEST(TryCatch, notImplementedExceptionNegative)
{
- using ::testing::StartsWith;
-
- Cynara::NotImplementedException e;
- ASSERT_THAT(e.what(), StartsWith("NotImplementedException"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::NotImplementedException>(
+ "NotImplementedException",
+ CYNARA_API_UNKNOWN_ERROR);
}
TEST(TryCatch, nullPointerExceptionNegative)
{
- using ::testing::StartsWith;
const std::string SOME_VAR = "someVar";
- Cynara::NullPointerException e(SOME_VAR.c_str());
- ASSERT_THAT(e.what(),
- StartsWith("unexpected null value in variable <" + SOME_VAR + ">"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::NullPointerException>(
+ "unexpected null value in variable <" + SOME_VAR + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_VAR.c_str());
}
TEST(TryCatch, outOfDataExceptionNegative)
{
- using ::testing::StartsWith;
-
const int SOME_RANGE = 42;
const int SOME_ACCESS = 4242;
- Cynara::OutOfDataException e(SOME_RANGE, SOME_ACCESS);
- ASSERT_THAT(e.what(),
- StartsWith("trying access [" + std::to_string(SOME_ACCESS) + "]"
- + " which exceeds data range [" + std::to_string(SOME_RANGE) + "]"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::OutOfDataException>(
+ "trying access [" + std::to_string(SOME_ACCESS) + "]"
+ + " which exceeds data range [" + std::to_string(SOME_RANGE) + "]",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_RANGE, SOME_ACCESS);
}
TEST(TryCatch, pluginErrorExceptionNegative)
{
- using ::testing::StartsWith;
-
const Cynara::PolicyKey SOME_KEY("someClient", "someUser", "somePrivilege");
- Cynara::PluginErrorException e(SOME_KEY);
- ASSERT_THAT(e.what(),
- StartsWith("Plugin couldn't get result for user <"
- + SOME_KEY.user().toString() + ">, "
- "client <" + SOME_KEY.client().toString() + ">, "
- "privilege <" + SOME_KEY.privilege().toString() + ">"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::PluginErrorException>(
+ "Plugin couldn't get result for user <"
+ + SOME_KEY.user().toString() + ">, "
+ "client <" + SOME_KEY.client().toString() + ">, "
+ "privilege <" + SOME_KEY.privilege().toString() + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_KEY);
}
TEST(TryCatch, pluginNotFoundExceptionNegative)
{
- using ::testing::StartsWith;
-
const Cynara::PolicyResult SOME_RESULT(42);
- Cynara::PluginNotFoundException e(SOME_RESULT);
- ASSERT_THAT(e.what(),
- StartsWith("No proper plugin found to interprete PolicyResult {type = ["
- + std::to_string(SOME_RESULT.policyType()) + "], metadata = <"
- + SOME_RESULT.metadata().substr(0, 20) + ">}"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::PluginNotFoundException>(
+ "No proper plugin found to interprete PolicyResult {type = ["
+ + std::to_string(SOME_RESULT.policyType()) + "], metadata = <"
+ + SOME_RESULT.metadata().substr(0, 20) + ">}",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_RESULT);
}
TEST(TryCatch, unexpectedErrorExceptionNegative)
{
- using ::testing::StartsWith;
-
const int SOME_ERROR_CODE = 42;
const char *SOME_ERROR_CSTR = "some error cstr";
- Cynara::UnexpectedErrorException e1(SOME_ERROR_CODE, SOME_ERROR_CSTR);
- ASSERT_THAT(e1.what(),
- StartsWith("UnexpectedErrorException with errorCode =["
- + std::to_string(SOME_ERROR_CODE)
- + "] and message <" + SOME_ERROR_CSTR + ">"));
- Cynara::UnexpectedErrorException e2(SOME_ERROR_CODE, SOME_ERROR);
- ASSERT_THAT(e2.what(),
- StartsWith("UnexpectedErrorException with errorCode =["
- + std::to_string(SOME_ERROR_CODE)
- + "] and message <" + SOME_ERROR + ">"));
- Cynara::UnexpectedErrorException e3(SOME_ERROR);
- ASSERT_THAT(e3.what(),
- StartsWith("UnexpectedErrorException with message <" + SOME_ERROR + ">"));
+ testException<Cynara::UnexpectedErrorException>(
+ "UnexpectedErrorException with errorCode =["
+ + std::to_string(SOME_ERROR_CODE)
+ + "] and message <" + SOME_ERROR_CSTR + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_ERROR_CODE, SOME_ERROR_CSTR);
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e1; return ret; };
+ testException<Cynara::UnexpectedErrorException>(
+ "UnexpectedErrorException with errorCode =["
+ + std::to_string(SOME_ERROR_CODE)
+ + "] and message <" + SOME_ERROR + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_ERROR_CODE, SOME_ERROR);
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::UnexpectedErrorException>(
+ "UnexpectedErrorException with message <" + SOME_ERROR + ">",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_ERROR);
}
TEST(TryCatch, unknownPolicyTypeExceptionNegative)
{
- using ::testing::StartsWith;
-
const Cynara::PolicyType SOME_POLICY_TYPE = 42;
- Cynara::UnknownPolicyTypeException e(SOME_POLICY_TYPE);
- ASSERT_THAT(e.what(),
- StartsWith("Unknown PolicyType [" + std::to_string(SOME_POLICY_TYPE) + "]"));
-
- int ret = CYNARA_API_SUCCESS;
- auto throwFun = [&]() { throw e; return ret; };
-
- ASSERT_NO_THROW(ret = Cynara::tryCatch(throwFun));
- ASSERT_EQ(ret, CYNARA_API_UNKNOWN_ERROR);
+ testException<Cynara::UnknownPolicyTypeException>(
+ "Unknown PolicyType [" + std::to_string(SOME_POLICY_TYPE) + "]",
+ CYNARA_API_UNKNOWN_ERROR,
+ SOME_POLICY_TYPE);
}
TEST(TryCatch, throwSomeNegative)