git subrepo clone --branch=20.41.6 git@github.com:ETLCPP/etl.git components/etl
subrepo: subdir: "components/etl" merged: "be5537ec" upstream: origin: "git@github.com:ETLCPP/etl.git" branch: "20.41.6" commit: "be5537ec" git-subrepo: version: "0.4.9" origin: "???" commit: "???"
This commit is contained in:
parent
931c4def56
commit
11c24647ea
1296 changed files with 801882 additions and 0 deletions
|
@ -0,0 +1,126 @@
|
|||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(etl_error_handler_unit_tests)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
add_definitions(-DETL_USE_ASSERT_FUNCTION)
|
||||
add_definitions(-DETL_VERBOSE_ERRORS)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../../../include)
|
||||
|
||||
set(TEST_SOURCE_FILES
|
||||
assert_function.cpp
|
||||
test_error_handler.cpp
|
||||
)
|
||||
|
||||
add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_CXX_STANDARD MATCHES "98")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "03")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "11")
|
||||
message(STATUS "Compiling for C++11")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 11)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "14")
|
||||
message(STATUS "Compiling for C++14")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "17")
|
||||
message(STATUS "Compiling for C++17")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "20")
|
||||
message(STATUS "Compiling for C++20")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20)
|
||||
else()
|
||||
message(STATUS "Compiling for C++23")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23)
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
message(STATUS "Using GCC compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
message(STATUS "Using Clang compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-Wno-deprecated-declarations
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-Wno-deprecated-declarations
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
if (ETL_ENABLE_SANITIZER MATCHES "ON")
|
||||
message(STATUS "Compiling with Sanitizer enabled")
|
||||
# MinGW doesn't presently support sanitization
|
||||
if (NOT MINGW)
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
# Since ctest will only show you the results of the single executable
|
||||
# define a target that will output all of the failing or passing tests
|
||||
# as they appear from UnitTest++
|
||||
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
#include "etl/exception.h"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#include "etl/exception.h"
|
||||
|
||||
extern void AssertFunction(const etl::exception& /*e*/);
|
||||
|
||||
#define ETL_ASSERT_FUNCTION AssertFunction
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,167 @@
|
|||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/std
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "etl/error_handler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "assert_function.h"
|
||||
|
||||
int assert_return_count = 0;
|
||||
int assert_count = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
void assert_function(const etl::exception& e)
|
||||
{
|
||||
std::cout << "Exception " << e.what() << " raised\n";
|
||||
|
||||
++assert_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception_1 : public test_exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception_1(string_type file_name_, numeric_type line_number_)
|
||||
: test_exception(ETL_ERROR_TEXT("Test Exception 1", "1A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
void Assert(bool state)
|
||||
{
|
||||
ETL_ASSERT(state, ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFail()
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertAndReturn(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(state, ETL_ERROR(test_exception_1));
|
||||
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFailAndReturn()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN(ETL_ERROR(test_exception_1));
|
||||
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertAndReturnValue(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(state, ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++assert_return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertFailAndReturnValue()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN_VALUE(ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++assert_return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
int main()
|
||||
{
|
||||
etl::set_assert_function(assert_function);
|
||||
|
||||
Assert(false);
|
||||
Assert(true);
|
||||
AssertFail();
|
||||
|
||||
AssertAndReturn(false);
|
||||
AssertAndReturn(true);
|
||||
AssertFailAndReturn();
|
||||
|
||||
if (AssertAndReturnValue(false))
|
||||
{
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
if (AssertAndReturnValue(true))
|
||||
{
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
if (AssertFailAndReturnValue())
|
||||
{
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
bool assert_count_passed = (assert_count == 6);
|
||||
|
||||
if (assert_count_passed)
|
||||
{
|
||||
std::cout << "Log Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Log Count Failed\n";
|
||||
}
|
||||
|
||||
bool return_count_passed = (assert_return_count == 4);
|
||||
|
||||
if (return_count_passed)
|
||||
{
|
||||
std::cout << "Return Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Return Count Failed\n";
|
||||
}
|
||||
|
||||
return (assert_count_passed && return_count_passed) ? 0 : 1;
|
||||
}
|
||||
|
122
components/etl/test/etl_error_handler/exceptions/CMakeLists.txt
Normal file
122
components/etl/test/etl_error_handler/exceptions/CMakeLists.txt
Normal file
|
@ -0,0 +1,122 @@
|
|||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(etl_error_handler_unit_tests)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
add_definitions(-DETL_THROW_EXCEPTIONS)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../../../include)
|
||||
|
||||
set(TEST_SOURCE_FILES
|
||||
test_error_handler.cpp
|
||||
)
|
||||
|
||||
add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_CXX_STANDARD MATCHES "98")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "03")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "11")
|
||||
message(STATUS "Compiling for C++11")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 11)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "14")
|
||||
message(STATUS "Compiling for C++14")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "17")
|
||||
message(STATUS "Compiling for C++17")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "20")
|
||||
message(STATUS "Compiling for C++20")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20)
|
||||
else()
|
||||
message(STATUS "Compiling for C++23")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23)
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
message(STATUS "Using GCC compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
message(STATUS "Using Clang compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
if (ETL_ENABLE_SANITIZER MATCHES "ON")
|
||||
message(STATUS "Compiling with Sanitizer enabled")
|
||||
# MinGW doesn't presently support sanitization
|
||||
if (NOT MINGW)
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
# Since ctest will only show you the results of the single executable
|
||||
# define a target that will output all of the failing or passing tests
|
||||
# as they appear from UnitTest++
|
||||
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|
||||
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/std
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "etl/error_handler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
//*****************************************************************************
|
||||
int exception_count = 0;
|
||||
int return_count = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception_1 : public test_exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception_1(string_type file_name_, numeric_type line_number_)
|
||||
: test_exception(ETL_ERROR_TEXT("Test Exception 1", "1A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
void Assert(bool state)
|
||||
{
|
||||
ETL_ASSERT(state, ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFail()
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertAndReturn(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(state, ETL_ERROR(test_exception_1));
|
||||
|
||||
++return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFailAndReturn()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN(ETL_ERROR(test_exception_1));
|
||||
|
||||
++return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertAndReturnValue(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(state, ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertFailAndReturnValue()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN_VALUE(ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Assert(false);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Assert(true);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertFail();
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertAndReturn(false);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertAndReturn(true);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertFailAndReturn();
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (AssertAndReturnValue(false))
|
||||
{
|
||||
++return_count;
|
||||
}
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (AssertAndReturnValue(true))
|
||||
{
|
||||
++return_count;
|
||||
}
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (AssertFailAndReturnValue())
|
||||
{
|
||||
++return_count;
|
||||
}
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
bool exception_count_passed = (exception_count == 6);
|
||||
|
||||
if (exception_count_passed)
|
||||
{
|
||||
std::cout << "Exception Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Exception Count Failed\n";
|
||||
}
|
||||
|
||||
bool return_count_passed = (return_count == 2);
|
||||
|
||||
if (return_count_passed)
|
||||
{
|
||||
std::cout << "Return Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Return Count Failed\n";
|
||||
}
|
||||
|
||||
return (exception_count_passed && return_count_passed) ? 0 : 1;
|
||||
}
|
||||
|
127
components/etl/test/etl_error_handler/log_errors/CMakeLists.txt
Normal file
127
components/etl/test/etl_error_handler/log_errors/CMakeLists.txt
Normal file
|
@ -0,0 +1,127 @@
|
|||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(etl_error_handler_unit_tests)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
add_definitions(-DETL_LOG_ERRORS)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../../../include)
|
||||
|
||||
set(TEST_SOURCE_FILES
|
||||
test_error_handler.cpp
|
||||
)
|
||||
|
||||
add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_CXX_STANDARD MATCHES "98")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "03")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "11")
|
||||
message(STATUS "Compiling for C++11")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 11)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "14")
|
||||
message(STATUS "Compiling for C++14")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "17")
|
||||
message(STATUS "Compiling for C++17")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "20")
|
||||
message(STATUS "Compiling for C++20")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20)
|
||||
else()
|
||||
message(STATUS "Compiling for C++23")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23)
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
message(STATUS "Using GCC compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
message(STATUS "Using Clang compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-fno-exceptions
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-fno-exceptions
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
if (ETL_ENABLE_SANITIZER MATCHES "ON")
|
||||
message(STATUS "Compiling with Sanitizer enabled")
|
||||
# MinGW doesn't presently support sanitization
|
||||
if (NOT MINGW)
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
# Since ctest will only show you the results of the single executable
|
||||
# define a target that will output all of the failing or passing tests
|
||||
# as they appear from UnitTest++
|
||||
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|
||||
|
||||
|
||||
#RSG
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/std
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "etl/error_handler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
//*****************************************************************************
|
||||
struct ErrorLog
|
||||
{
|
||||
ErrorLog()
|
||||
: log_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Log(const etl::exception& /*e*/)
|
||||
{
|
||||
++log_count;
|
||||
}
|
||||
|
||||
int log_count;
|
||||
};
|
||||
|
||||
int assert_return_count = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception_1 : public test_exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception_1(string_type file_name_, numeric_type line_number_)
|
||||
: test_exception(ETL_ERROR_TEXT("Test Exception 1", "1A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
void Assert(bool state)
|
||||
{
|
||||
ETL_ASSERT(state, ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFail()
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertAndReturn(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(state, ETL_ERROR(test_exception_1));
|
||||
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFailAndReturn()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN(ETL_ERROR(test_exception_1));
|
||||
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertAndReturnValue(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(state, ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++assert_return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertFailAndReturnValue()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN_VALUE(ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++assert_return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
int main()
|
||||
{
|
||||
static ErrorLog error_log;
|
||||
|
||||
etl::error_handler::set_callback<ErrorLog, error_log, &ErrorLog::Log>();
|
||||
|
||||
Assert(false);
|
||||
Assert(true);
|
||||
AssertFail();
|
||||
|
||||
AssertAndReturn(false);
|
||||
AssertAndReturn(true);
|
||||
AssertFailAndReturn();
|
||||
|
||||
if (AssertAndReturnValue(false))
|
||||
{
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
if (AssertAndReturnValue(true))
|
||||
{
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
if (AssertFailAndReturnValue())
|
||||
{
|
||||
++assert_return_count;
|
||||
}
|
||||
|
||||
bool log_count_passed = (error_log.log_count == 6);
|
||||
|
||||
if (log_count_passed)
|
||||
{
|
||||
std::cout << "Log Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Log Count Failed\n";
|
||||
}
|
||||
|
||||
bool return_count_passed = (assert_return_count == 4);
|
||||
|
||||
if (return_count_passed)
|
||||
{
|
||||
std::cout << "Return Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Return Count Failed\n";
|
||||
}
|
||||
|
||||
return (log_count_passed && return_count_passed) ? 0 : 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(etl_error_handler_unit_tests)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
add_definitions(-DETL_THROW_EXCEPTIONS)
|
||||
add_definitions(-DETL_LOG_ERRORS)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/../../../include)
|
||||
|
||||
set(TEST_SOURCE_FILES
|
||||
test_error_handler.cpp
|
||||
)
|
||||
|
||||
add_executable(etl_tests
|
||||
${TEST_SOURCE_FILES}
|
||||
)
|
||||
|
||||
if (ETL_CXX_STANDARD MATCHES "98")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "03")
|
||||
message(STATUS "Compiling for C++98")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 98)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "11")
|
||||
message(STATUS "Compiling for C++11")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 11)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "14")
|
||||
message(STATUS "Compiling for C++14")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 14)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "17")
|
||||
message(STATUS "Compiling for C++17")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
elseif (ETL_CXX_STANDARD MATCHES "20")
|
||||
message(STATUS "Compiling for C++20")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20)
|
||||
else()
|
||||
message(STATUS "Compiling for C++23")
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23)
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O1")
|
||||
message(STATUS "Compiling with -O1 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O2")
|
||||
message(STATUS "Compiling with -O2 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
endif()
|
||||
|
||||
if (ETL_OPTIMISATION MATCHES "-O3")
|
||||
message(STATUS "Compiling with -O3 optimisations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
endif()
|
||||
|
||||
target_include_directories(etl_tests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
message(STATUS "Using GCC compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
message(STATUS "Using Clang compiler")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fno-omit-frame-pointer
|
||||
-fno-common
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfloat-equal
|
||||
-Wshadow
|
||||
-Wnull-dereference
|
||||
)
|
||||
endif ()
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
if (ETL_ENABLE_SANITIZER MATCHES "ON")
|
||||
message(STATUS "Compiling with Sanitizer enabled")
|
||||
# MinGW doesn't presently support sanitization
|
||||
if (NOT MINGW)
|
||||
target_compile_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
|
||||
target_link_options(etl_tests
|
||||
PRIVATE
|
||||
-fsanitize=address,undefined,bounds
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Enable the 'make test' CMake target using the executable defined above
|
||||
add_test(etl_error_handler_unit_tests etl_tests)
|
||||
|
||||
# Since ctest will only show you the results of the single executable
|
||||
# define a target that will output all of the failing or passing tests
|
||||
# as they appear from UnitTest++
|
||||
add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|
||||
|
||||
|
||||
#RSG
|
||||
set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17)
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/std
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "etl/error_handler.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
//*****************************************************************************
|
||||
struct ErrorLog
|
||||
{
|
||||
ErrorLog()
|
||||
: log_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Log(const etl::exception& /*e*/)
|
||||
{
|
||||
++log_count;
|
||||
}
|
||||
|
||||
int log_count;
|
||||
};
|
||||
|
||||
int exception_count = 0;
|
||||
int return_count = 0;
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception : public etl::exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
class test_exception_1 : public test_exception
|
||||
{
|
||||
public:
|
||||
|
||||
test_exception_1(string_type file_name_, numeric_type line_number_)
|
||||
: test_exception(ETL_ERROR_TEXT("Test Exception 1", "1A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
void Assert(bool state)
|
||||
{
|
||||
ETL_ASSERT(state, ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFail()
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(test_exception_1));
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertAndReturn(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN(state, ETL_ERROR(test_exception_1));
|
||||
|
||||
++return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
void AssertFailAndReturn()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN(ETL_ERROR(test_exception_1));
|
||||
|
||||
++return_count;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertAndReturnValue(bool state)
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(state, ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
bool AssertFailAndReturnValue()
|
||||
{
|
||||
ETL_ASSERT_FAIL_AND_RETURN_VALUE(ETL_ERROR(test_exception_1), true);
|
||||
|
||||
++return_count;
|
||||
return false;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
int main()
|
||||
{
|
||||
ErrorLog error_log;
|
||||
|
||||
etl::error_handler::set_callback<ErrorLog, &ErrorLog::Log>(error_log);
|
||||
|
||||
try
|
||||
{
|
||||
Assert(false);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Assert(true);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertFail();
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertAndReturn(false);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertAndReturn(true);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertFailAndReturn();
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertAndReturnValue(false);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertAndReturnValue(true);
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AssertFailAndReturnValue();
|
||||
}
|
||||
catch (test_exception_1 e)
|
||||
{
|
||||
++exception_count;
|
||||
}
|
||||
|
||||
bool log_count_passed = (error_log.log_count == 6);
|
||||
|
||||
if (log_count_passed)
|
||||
{
|
||||
std::cout << "Log Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Log Count Failed\n";
|
||||
}
|
||||
|
||||
bool return_count_passed = (return_count == 2);
|
||||
|
||||
if (return_count_passed)
|
||||
{
|
||||
std::cout << "Return Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Return Count Failed\n";
|
||||
}
|
||||
|
||||
bool exception_count_passed = (exception_count == 6);
|
||||
|
||||
if (exception_count_passed)
|
||||
{
|
||||
std::cout << "Exception Count Passed\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Exception Count Failed\n";
|
||||
}
|
||||
|
||||
return (log_count_passed && return_count_passed && exception_count_passed) ? 0 : 1;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue