VS integration part 1 - allow catch_message.hpp to be included by more than 1 source file

This commit is contained in:
Malcolm Noyes
2013-11-10 15:11:21 +00:00
parent 8e411d27f6
commit e9a2230ad8
8 changed files with 165 additions and 18 deletions

View File

@@ -0,0 +1,50 @@
/*
* Created by Phil on 09/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include "catch.hpp"
#undef INTERNAL_CATCH_INLINE
#define INTERNAL_CATCH_INLINE inline
#include "internal/catch_message.hpp"
namespace Counter {
int g_haveCountedMessages = 0;
}
// This test works with the equivalent in MessageInstantiationTests2.cpp
// The first test to reach this point will increment the MessageInfo counter. Subsequent tests
// just check the value. The purpose of this test is to verify that the compiler's
// greedy instantiation (or whatever process it uses) eliminate all other
// references to the globalCount
TEST_CASE("message counting1","")
{
if( Counter::g_haveCountedMessages > 0 ) {
REQUIRE( Catch::MessageInfoCounter<unsigned int>::globalCount > 0 );
}
else
{
++Catch::MessageInfoCounter<unsigned int>::globalCount;
Counter::g_haveCountedMessages = 1;
}
}
namespace LongCounter {
int g_haveCountedMessagesLong = 0;
}
TEST_CASE("long message counting1","")
{
if( LongCounter::g_haveCountedMessagesLong > 0 ) {
REQUIRE( Catch::MessageInfoCounter<long>::globalCount > 0 );
}
else
{
++Catch::MessageInfoCounter<long>::globalCount;
LongCounter::g_haveCountedMessagesLong = 1;
}
}

View File

@@ -0,0 +1,49 @@
/*
* Created by Phil on 09/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include "catch.hpp"
#define INTERNAL_CATCH_INLINE inline
#include "internal/catch_message.hpp"
namespace Counter {
extern int g_haveCountedMessages;
}
// This test works with the equivalent in MessageInstantiationTests1.cpp
// The first test to reach this point will increment the MessageInfo counter. Subsequent tests
// just check the value. The purpose of this test is to verify that the compiler's
// greedy instantiation (or whatever process it uses) eliminate all other
// references to the globalCount
TEST_CASE("message counting2","")
{
if( Counter::g_haveCountedMessages > 0 ) {
REQUIRE( Catch::MessageInfoCounter<unsigned int>::globalCount > 0 );
}
else
{
++Catch::MessageInfoCounter<unsigned int>::globalCount;
Counter::g_haveCountedMessages = 1;
}
}
namespace LongCounter {
extern int g_haveCountedMessagesLong;
}
TEST_CASE("long message counting2","")
{
if( LongCounter::g_haveCountedMessagesLong > 0 ) {
REQUIRE( Catch::MessageInfoCounter<long>::globalCount > 0 );
}
else
{
++Catch::MessageInfoCounter<long>::globalCount;
LongCounter::g_haveCountedMessagesLong = 1;
}
}

View File

@@ -4,6 +4,8 @@ SOURCES = ApproxTests.cpp \
ExceptionTests.cpp \
GeneratorTests.cpp \
MessageTests.cpp \
MessageInstantiationTests1.cpp \
MessageInstantiationTests2.cpp \
MiscTests.cpp \
TestMain.cpp \
TrickyTests.cpp \
@@ -18,4 +20,4 @@ CatchSelfTest: $(OBJECTS)
$(CXX) -o $@ $^
clean:
rm -f $(OBJECTS)
rm -f CatchSelfTest CatchSelfTest.exe $(OBJECTS)

View File

@@ -94,6 +94,8 @@
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\MessageInstantiationTests1.cpp" />
<ClCompile Include="..\..\..\SelfTest\MessageInstantiationTests2.cpp" />
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
<ClCompile Include="..\..\..\SelfTest\catch_self_test.cpp" />
@@ -108,42 +110,81 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\include\catch.hpp" />
<ClInclude Include="..\..\..\..\include\catch_objc.hpp" />
<ClInclude Include="..\..\..\..\include\catch_objc_main.hpp" />
<ClInclude Include="..\..\..\..\include\catch_runner.hpp" />
<ClInclude Include="..\..\..\..\include\catch_with_main.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_approx.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_assertionresult.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_assertionresult.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_capture.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_commandline.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_common.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_compiler_capabilities.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_config.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_console_colour.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_console_colour_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_context.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_context_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_debugger.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_default_main.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_evaluate.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_exception_translator_registry.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_expressionresult_builder.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_expressionresult_builder.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_expression_decomposer.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_expression_lhs.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_generators.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_generators_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_hub.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_hub_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_capture.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_config.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_exception.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_generators.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_registry_hub.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_reporter.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_runner.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_interfaces_testcase.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_legacy_reporter_adapter.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_legacy_reporter_adapter.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_list.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_matchers.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_message.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_message.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_notimplemented_exception.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_notimplemented_exception.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_objc.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_objc_arc.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_option.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_platform.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_ptr.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_registry_hub.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_reporter_registrars.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_reporter_registry.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_result_type.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_resultinfo.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_runner_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_section.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_self_test.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_sfinae.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_stream.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_streambuf.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_tags.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_info.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_info.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_registry_impl.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_tracker.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_test_registry.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_test_spec.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_text.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_text.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_timer.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_timer.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_tostring.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_totals.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_version.h" />
<ClInclude Include="..\..\..\..\include\internal\catch_version.hpp" />
<ClInclude Include="..\..\..\..\include\internal\catch_xmlwriter.hpp" />
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_basic.hpp" />
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_console.hpp" />
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_junit.hpp" />
<ClInclude Include="..\..\..\..\include\reporters\catch_reporter_xml.hpp" />
<ClInclude Include="..\..\..\selftest\catch_self_test.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />