Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update scoped_trace_exception_tests #688

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions projects/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ if (build_tests)
cxx_executable_test(random_seed_tests)
cxx_executable_test(record_property_tests)
cxx_executable_test(repeat_tests)
cxx_executable_test(scoped_trace_exception_tests)
cxx_executable_test(scoped_trace_tests)
cxx_executable_test(set_up_failure_tests)
cxx_executable_test(set_up_global_failure_tests)
Expand Down Expand Up @@ -320,7 +321,6 @@ if (build_tests)
cxx_executable_test(param_test_name_invalid_tests)
cxx_executable_test(param_test_name_tests)
cxx_executable_test(no_yoda_tests)
cxx_executable_test(scoped_trace_exception_tests)
cxx_executable_test(spec_tests)
cxx_executable_test(tap_file_generator_listener_tests)
cxx_executable_test(tap_printer_listener_tests)
Expand Down Expand Up @@ -396,6 +396,7 @@ if (build_tests)
cxx_add_test(random_seed_tests)
cxx_add_test(record_property_tests)
cxx_add_test(repeat_tests)
cxx_add_test(scoped_trace_exception_tests)
cxx_add_test(scoped_trace_tests)
cxx_add_test(set_up_failure_tests)
cxx_add_test(set_up_global_failure_tests)
Expand Down Expand Up @@ -436,7 +437,6 @@ if (build_tests)
cxx_add_test(param_test_name_invalid_tests)
cxx_add_test(param_test_name_tests)
cxx_add_test(no_yoda_tests)
cxx_add_test(scoped_trace_exception_tests)
cxx_add_test(spec_tests)
cxx_add_test(tap_file_generator_listener_tests)
cxx_add_test(tap_printer_listener_tests)
Expand Down
24 changes: 23 additions & 1 deletion projects/vscode/iutest.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,29 @@
"version": "cpp",
"*.defs": "cpp"
},
"bracketLens.minBracketScopeLines": 12
"bracketLens.minBracketScopeLines": 12,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "googletest.failed",
"settings": {
"foreground": "#f00"
}
},
{
"scope": "googletest.passed",
"settings": {
"foreground": "#0f0"
}
},
{
"scope": "googletest.run",
"settings": {
"foreground": "#0f0"
}
}
]
}
},
"launch": {
"configurations": [
Expand Down
2 changes: 1 addition & 1 deletion test/CommonMakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ TEST_TARGETS= \
$(OUTDIR)/random_seed_tests \
$(OUTDIR)/record_property_tests \
$(OUTDIR)/repeat_tests \
$(OUTDIR)/scoped_trace_exception_tests \
$(OUTDIR)/scoped_trace_tests \
$(OUTDIR)/set_up_failure_tests \
$(OUTDIR)/set_up_global_failure_tests \
Expand Down Expand Up @@ -184,7 +185,6 @@ TARGETS_IUTEST_ONLY = \
$(OUTDIR)/param_test_name_invalid_tests \
$(OUTDIR)/param_test_name_tests \
$(OUTDIR)/no_yoda_tests \
$(OUTDIR)/scoped_trace_exception_tests \
$(OUTDIR)/tap_file_generator_listener_tests \
$(OUTDIR)/tap_printer_listener_tests \
$(OUTDIR)/type_param_register_exception_int_tests \
Expand Down
24 changes: 19 additions & 5 deletions test/scoped_trace_exception_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
#include "iutest.hpp"
#include "logger_tests.hpp"

#if defined(IUTEST_USE_GTEST)
# if GTEST_VER <= 0x01080000
# define SCOPED_TRACE_EXCEPTION_TEST 0
# endif
#endif

#if !defined(SCOPED_TRACE_EXCEPTION_TEST)
# define SCOPED_TRACE_EXCEPTION_TEST 1
#endif

#if defined(IUTEST_USE_GTEST)
# define EXCEPTION_CATCH_TEST 0
#endif
Expand All @@ -30,8 +40,6 @@
# endif
#endif

#if EXCEPTION_CATCH_TEST

bool no_throw = false;

IUTEST(ScopedTraceExceptionTest, Exception)
Expand Down Expand Up @@ -92,15 +100,13 @@ IUTEST_F(DISABLED_ScopedTraceExceptionSetUpTest, Empty)
{
}

#endif

#ifdef UNICODE
int wmain(int argc, wchar_t* argv[])
#else
int main(int argc, char* argv[])
#endif
{
#if EXCEPTION_CATCH_TEST
#if SCOPED_TRACE_EXCEPTION_TEST
IUTEST_INIT(&argc, argv);
::iutest::IUTEST_FLAG(catch_exceptions) = true;
#if defined(DISABLE_FALSE_POSITIVE_XML)
Expand All @@ -112,8 +118,10 @@ int main(int argc, char* argv[])
IUTEST_ASSERT_NE(IUTEST_RUN_ALL_TESTS(), 0)
<< ::iutest::AssertionReturn<int>(1);

#if !defined(IUTEST_USE_GTEST)
TestLogger logger;
::iutest::detail::iuConsole::SetLogger(&logger);
#endif

try
{
Expand All @@ -130,6 +138,7 @@ int main(int argc, char* argv[])
if( ret == 0 ) return 1;
}

#if EXCEPTION_CATCH_TEST
IUTEST_ASSERT_STRIN( "ScopedTraceExceptionTest Scoped Exception A", logger.c_str())
<< ::iutest::AssertionReturn<int>(1);
IUTEST_ASSERT_STRNOTIN("ScopedTraceExceptionTest Scoped Exception B", logger.c_str())
Expand All @@ -148,14 +157,18 @@ int main(int argc, char* argv[])
<< ::iutest::AssertionReturn<int>(1);
IUTEST_ASSERT_STRNOTIN("ScopedTraceExceptionTest Scoped Assertion B", logger.c_str())
<< ::iutest::AssertionReturn<int>(1);
#endif

no_throw = true;
#if !defined(IUTEST_USE_GTEST)
logger.clear();
#endif
{
const int ret = IUTEST_RUN_ALL_TESTS();
if( ret != 0 ) return 1;
}

#if EXCEPTION_CATCH_TEST
IUTEST_ASSERT_STRNOTIN("ScopedTraceExceptionTest Scoped Exception A", logger.c_str())
<< ::iutest::AssertionReturn<int>(1);
IUTEST_ASSERT_STRNOTIN("ScopedTraceExceptionTest Scoped Exception B", logger.c_str())
Expand All @@ -164,6 +177,7 @@ int main(int argc, char* argv[])
<< ::iutest::AssertionReturn<int>(1);
IUTEST_ASSERT_STRNOTIN("ScopedTraceExceptionTest Scoped Exception D", logger.c_str())
<< ::iutest::AssertionReturn<int>(1);
#endif

#else
IUTEST_UNUSED_VAR(argc);
Expand Down
Loading