EXPECT_EQ(retVal, WAUTHN_ERROR_NOT_SUPPORTED)
<< "[wauthn_process<TestClientRequestMC>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
sleep(1);
EXPECT_EQ(userdata->called_qr, false)
<< "The QR callback should not be called by cancel" << std::endl;
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
// Waiting for called the callbacks
sleep(g_target_times_update_linked_data + 5);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
// Waiting for called the callbacks
sleep(g_target_times_update_linked_data + 5);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestGA>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
// Waiting for called the callbacks
sleep(g_target_times_update_linked_data + 5);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestGA>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
// Waiting for called the callbacks
sleep(g_target_times_update_linked_data + 5);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
sleep(1);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
- << "retVal=" << wauthn_error_to_string(ret) << std::endl;
+ << "retVal=" << wauthn_error_to_string(retVal) << std::endl;
TestClientRequest request(WebAuthnCall::CANCEL);
request.Init();
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ *
+ *
+ * @file dl-loader-test.cpp
+ * @version 1.0
+ * @brief unit tests for dl-loader
+ */
+
+#include <gtest/gtest.h>
+#include <iostream>
+#include <utils.h>
+
+
+namespace WA {
+
+class UtilsTest : public ::testing::Test {
+protected:
+ void SetUp() override {
+ // Do initialization if needed.
+ }
+
+ void TearDown() override {
+ // Do deinitialization if needed.
+ }
+};
+
+TEST_F(UtilsTest, handle_exceptions_by_try_catch_function_P)
+{
+ int ret = try_catch([&]() -> int {
+ Throw(SerializationException::InvalidStreamData);
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ Throw(MessageBufferException::OutOfData);
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_MEMORY);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ Throw(ServiceException::InvalidAction);
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_STATE);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ Throw(ServiceException::InActive);
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_SOCKET);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ Throw(FileLockerException::LockFailed);
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_STATE);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ Throw(SocketManagerException::InitFailed);
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_STATE);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ throw std::logic_error("logic error");
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_STATE);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ throw std::bad_alloc();
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_MEMORY);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ throw std::system_error();
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_UNKNOWN);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ throw std::exception();
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_UNKNOWN);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ throw std::overflow_error("overflow_error");
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_UNKNOWN);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+ ret = try_catch([&]() -> int {
+ return WAUTHN_ERROR_NONE;
+ });
+ EXPECT_EQ(ret, WAUTHN_ERROR_NONE);
+ std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
+
+}
+
+} // namespace WebAuthn