From 3cc317163dcd028eaa207293ea9e09c55246aa16 Mon Sep 17 00:00:00 2001 From: Alecto Irene Perez Date: Tue, 22 Mar 2022 20:26:17 -0600 Subject: [PATCH 1/7] Enable building Catch2 as a dynamic library Signed-off-by: Alecto Irene Perez --- src/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78d95956dd..f68dbf2233 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -251,9 +251,7 @@ set(REPORTER_SOURCES ) set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES}) -# Fixme: STATIC because for dynamic, we would need to handle visibility -# and I don't want to do the annotations right now -add_library(Catch2 STATIC +add_library(Catch2 ${REPORTER_FILES} ${INTERNAL_FILES} ${BENCHMARK_HEADERS} @@ -306,7 +304,7 @@ target_include_directories(Catch2 ) -add_library(Catch2WithMain STATIC +add_library(Catch2WithMain ${SOURCES_DIR}/internal/catch_main.cpp ) add_build_reproducibility_settings(Catch2WithMain) From aef77b7666307bfdfe9b2c56d3f65fe61572762b Mon Sep 17 00:00:00 2001 From: Alecto Irene Perez Date: Tue, 26 Apr 2022 16:29:48 -0600 Subject: [PATCH 2/7] Make default visibility hidden This commit makes the default visibility hidden, and annotates the necessary types and classes to be public --- src/CMakeLists.txt | 3 + src/catch2/benchmark/catch_benchmark.hpp | 24 +- src/catch2/benchmark/catch_chronometer.hpp | 8 +- src/catch2/benchmark/catch_clock.hpp | 4 +- src/catch2/benchmark/catch_constructor.hpp | 2 +- src/catch2/benchmark/catch_environment.hpp | 6 +- src/catch2/benchmark/catch_estimate.hpp | 5 +- src/catch2/benchmark/catch_execution_plan.hpp | 9 +- src/catch2/benchmark/catch_optimizer.hpp | 2 +- .../catch_outlier_classification.hpp | 4 +- .../benchmark/catch_sample_analysis.hpp | 9 +- .../detail/catch_benchmark_function.hpp | 6 +- .../detail/catch_run_for_at_least.hpp | 4 +- src/catch2/benchmark/detail/catch_stats.hpp | 24 +- src/catch2/catch_all.hpp | 1 + src/catch2/catch_approx.hpp | 8 +- src/catch2/catch_assertion_info.hpp | 3 +- src/catch2/catch_assertion_result.hpp | 9 +- src/catch2/catch_config.hpp | 20 +- src/catch2/catch_message.hpp | 16 +- src/catch2/catch_section_info.hpp | 8 +- src/catch2/catch_session.hpp | 7 +- src/catch2/catch_tag_alias.hpp | 4 +- src/catch2/catch_tag_alias_autoregistrar.hpp | 5 +- src/catch2/catch_test_case_info.hpp | 21 +- src/catch2/catch_test_spec.hpp | 14 +- src/catch2/catch_timer.hpp | 3 +- src/catch2/catch_tostring.hpp | 64 ++- src/catch2/catch_totals.hpp | 5 +- src/catch2/catch_translate_exception.hpp | 9 +- src/catch2/catch_version.hpp | 6 +- .../generators/catch_generator_exception.hpp | 3 +- src/catch2/generators/catch_generators.hpp | 63 ++- .../generators/catch_generators_adapters.hpp | 17 +- .../generators/catch_generators_random.hpp | 86 ++- .../generators/catch_generators_range.hpp | 64 ++- .../interfaces/catch_interfaces_capture.hpp | 12 +- .../interfaces/catch_interfaces_config.hpp | 48 +- .../catch_interfaces_enum_values_registry.hpp | 6 +- .../interfaces/catch_interfaces_exception.hpp | 6 +- .../catch_interfaces_generatortracker.hpp | 5 +- .../catch_interfaces_registry_hub.hpp | 15 +- .../interfaces/catch_interfaces_reporter.hpp | 36 +- .../catch_interfaces_reporter_factory.hpp | 7 +- .../catch_interfaces_reporter_registry.hpp | 6 +- .../catch_interfaces_tag_alias_registry.hpp | 3 +- .../interfaces/catch_interfaces_testcase.hpp | 5 +- .../internal/catch_assertion_handler.hpp | 11 +- .../catch_case_insensitive_comparisons.hpp | 8 +- src/catch2/internal/catch_case_sensitive.hpp | 4 +- src/catch2/internal/catch_clara.hpp | 88 ++-- src/catch2/internal/catch_commandline.hpp | 2 +- src/catch2/internal/catch_console_colour.hpp | 16 +- src/catch2/internal/catch_context.hpp | 12 +- src/catch2/internal/catch_debug_console.hpp | 1 + src/catch2/internal/catch_debugger.hpp | 1 + src/catch2/internal/catch_decomposer.hpp | 30 +- src/catch2/internal/catch_dll_public.hpp | 33 ++ src/catch2/internal/catch_enforce.hpp | 16 +- .../internal/catch_enum_values_registry.hpp | 11 +- src/catch2/internal/catch_errno_guard.hpp | 5 +- .../catch_exception_translator_registry.hpp | 7 +- .../catch_fatal_condition_handler.hpp | 10 +- .../internal/catch_floating_point_helpers.hpp | 8 +- src/catch2/internal/catch_lazy_expr.hpp | 7 +- src/catch2/internal/catch_leak_detector.hpp | 5 +- src/catch2/internal/catch_list.hpp | 8 +- src/catch2/internal/catch_message_info.hpp | 6 +- src/catch2/internal/catch_meta.hpp | 9 +- src/catch2/internal/catch_noncopyable.hpp | 4 +- src/catch2/internal/catch_optional.hpp | 12 +- src/catch2/internal/catch_output_redirect.hpp | 17 +- src/catch2/internal/catch_polyfills.hpp | 6 +- src/catch2/internal/catch_preprocessor.hpp | 189 +++++-- .../catch_random_number_generator.hpp | 9 +- .../internal/catch_random_seed_generation.hpp | 5 +- .../internal/catch_reporter_registry.hpp | 4 +- src/catch2/internal/catch_result_type.hpp | 53 +- src/catch2/internal/catch_run_context.hpp | 20 +- src/catch2/internal/catch_section.hpp | 7 +- src/catch2/internal/catch_singletons.hpp | 12 +- .../internal/catch_source_line_info.hpp | 6 +- .../catch_startup_exception_registry.hpp | 6 +- src/catch2/internal/catch_stream.hpp | 16 +- src/catch2/internal/catch_stream_end_stop.hpp | 3 +- src/catch2/internal/catch_string_manip.hpp | 39 +- src/catch2/internal/catch_stringref.hpp | 20 +- .../internal/catch_tag_alias_registry.hpp | 6 +- .../internal/catch_template_test_registry.hpp | 489 +++++++++++------- .../catch_test_case_registry_impl.hpp | 8 +- .../internal/catch_test_case_tracker.hpp | 17 +- .../internal/catch_test_failure_exception.hpp | 4 +- src/catch2/internal/catch_test_registry.hpp | 113 ++-- .../internal/catch_test_spec_parser.hpp | 9 +- src/catch2/internal/catch_textflow.hpp | 25 +- src/catch2/internal/catch_to_string.hpp | 4 +- src/catch2/internal/catch_unique_ptr.hpp | 7 +- src/catch2/internal/catch_void_type.hpp | 6 +- .../internal/catch_wildcard_pattern.hpp | 4 +- src/catch2/internal/catch_windows_h_proxy.hpp | 1 + src/catch2/internal/catch_xmlwriter.hpp | 21 +- src/catch2/matchers/catch_matchers.hpp | 23 +- .../catch_matchers_container_properties.hpp | 17 +- .../matchers/catch_matchers_contains.hpp | 12 +- .../matchers/catch_matchers_exception.hpp | 21 +- .../catch_matchers_floating_point.hpp | 25 +- .../matchers/catch_matchers_predicate.hpp | 8 +- .../matchers/catch_matchers_quantifiers.hpp | 12 +- src/catch2/matchers/catch_matchers_string.hpp | 38 +- .../matchers/catch_matchers_templated.hpp | 37 +- src/catch2/matchers/catch_matchers_vector.hpp | 32 +- .../matchers/internal/catch_matchers_impl.hpp | 5 +- .../reporters/catch_reporter_automake.hpp | 4 +- .../reporters/catch_reporter_common_base.hpp | 5 +- .../reporters/catch_reporter_compact.hpp | 6 +- .../reporters/catch_reporter_console.hpp | 5 +- .../catch_reporter_cumulative_base.hpp | 17 +- .../catch_reporter_event_listener.hpp | 3 +- .../reporters/catch_reporter_helpers.hpp | 33 +- src/catch2/reporters/catch_reporter_junit.hpp | 8 +- src/catch2/reporters/catch_reporter_multi.hpp | 5 +- .../reporters/catch_reporter_registrars.hpp | 13 +- .../reporters/catch_reporter_sonarqube.hpp | 7 +- .../catch_reporter_streaming_base.hpp | 4 +- src/catch2/reporters/catch_reporter_tap.hpp | 3 +- .../reporters/catch_reporter_teamcity.hpp | 6 +- src/catch2/reporters/catch_reporter_xml.hpp | 9 +- 127 files changed, 1421 insertions(+), 1072 deletions(-) create mode 100644 src/catch2/internal/catch_dll_public.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f68dbf2233..84ac65e546 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,6 +70,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/internal/catch_debug_console.hpp ${SOURCES_DIR}/internal/catch_debugger.hpp ${SOURCES_DIR}/internal/catch_decomposer.hpp + ${SOURCES_DIR}/internal/catch_dll_public.hpp ${SOURCES_DIR}/internal/catch_enforce.hpp ${SOURCES_DIR}/internal/catch_enum_values_registry.hpp ${SOURCES_DIR}/internal/catch_errno_guard.hpp @@ -257,6 +258,8 @@ add_library(Catch2 ${BENCHMARK_HEADERS} ${BENCHMARK_SOURCES} ) +set_target_properties(Catch2 PROPERTIES CXX_VISIBILITY_PRESET hidden) + add_build_reproducibility_settings(Catch2) add_library(Catch2::Catch2 ALIAS Catch2) diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp index 28664b613e..5ed745e681 100644 --- a/src/catch2/benchmark/catch_benchmark.hpp +++ b/src/catch2/benchmark/catch_benchmark.hpp @@ -10,31 +10,31 @@ #ifndef CATCH_BENCHMARK_HPP_INCLUDED #define CATCH_BENCHMARK_HPP_INCLUDED -#include -#include -#include -#include -#include -#include +#include #include #include #include #include -#include -#include #include #include +#include +#include #include - -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include namespace Catch { namespace Benchmark { - struct Benchmark { + struct CATCH_DLL_PUBLIC Benchmark { Benchmark(std::string&& benchmarkName) : name(CATCH_MOVE(benchmarkName)) {} diff --git a/src/catch2/benchmark/catch_chronometer.hpp b/src/catch2/benchmark/catch_chronometer.hpp index 7ef08cef0d..64594d5868 100644 --- a/src/catch2/benchmark/catch_chronometer.hpp +++ b/src/catch2/benchmark/catch_chronometer.hpp @@ -13,13 +13,14 @@ #include #include #include +#include #include #include namespace Catch { namespace Benchmark { namespace Detail { - struct ChronometerConcept { + struct CATCH_DLL_PUBLIC ChronometerConcept { virtual void start() = 0; virtual void finish() = 0; virtual ~ChronometerConcept(); // = default; @@ -29,7 +30,8 @@ namespace Catch { ChronometerConcept& operator=(ChronometerConcept const&) = default; }; template - struct ChronometerModel final : public ChronometerConcept { + struct CATCH_DLL_PUBLIC ChronometerModel final + : public ChronometerConcept { void start() override { started = Clock::now(); } void finish() override { finished = Clock::now(); } @@ -40,7 +42,7 @@ namespace Catch { }; } // namespace Detail - struct Chronometer { + struct CATCH_DLL_PUBLIC Chronometer { public: template void measure(Fun&& fun) { measure(CATCH_FORWARD(fun), is_callable()); } diff --git a/src/catch2/benchmark/catch_clock.hpp b/src/catch2/benchmark/catch_clock.hpp index e0cf4aaeb4..e00e7f6e64 100644 --- a/src/catch2/benchmark/catch_clock.hpp +++ b/src/catch2/benchmark/catch_clock.hpp @@ -10,6 +10,7 @@ #ifndef CATCH_CLOCK_HPP_INCLUDED #define CATCH_CLOCK_HPP_INCLUDED +#include #include #include @@ -25,8 +26,7 @@ namespace Catch { using default_clock = std::chrono::steady_clock; - template - struct now { + template struct CATCH_DLL_PUBLIC now { TimePoint operator()() const { return Clock::now(); } diff --git a/src/catch2/benchmark/catch_constructor.hpp b/src/catch2/benchmark/catch_constructor.hpp index 9da1eaaf8c..43f9d3206d 100644 --- a/src/catch2/benchmark/catch_constructor.hpp +++ b/src/catch2/benchmark/catch_constructor.hpp @@ -10,8 +10,8 @@ #ifndef CATCH_CONSTRUCTOR_HPP_INCLUDED #define CATCH_CONSTRUCTOR_HPP_INCLUDED +#include #include - #include namespace Catch { diff --git a/src/catch2/benchmark/catch_environment.hpp b/src/catch2/benchmark/catch_environment.hpp index cadd7bc392..f15319c923 100644 --- a/src/catch2/benchmark/catch_environment.hpp +++ b/src/catch2/benchmark/catch_environment.hpp @@ -12,11 +12,12 @@ #include #include +#include namespace Catch { namespace Benchmark { template - struct EnvironmentEstimate { + struct CATCH_DLL_PUBLIC EnvironmentEstimate { Duration mean; OutlierClassification outliers; @@ -25,8 +26,7 @@ namespace Catch { return { mean, outliers }; } }; - template - struct Environment { + template struct CATCH_DLL_PUBLIC Environment { using clock_type = Clock; EnvironmentEstimate> clock_resolution; EnvironmentEstimate> clock_cost; diff --git a/src/catch2/benchmark/catch_estimate.hpp b/src/catch2/benchmark/catch_estimate.hpp index 884a4614ea..f91df2df7d 100644 --- a/src/catch2/benchmark/catch_estimate.hpp +++ b/src/catch2/benchmark/catch_estimate.hpp @@ -10,10 +10,11 @@ #ifndef CATCH_ESTIMATE_HPP_INCLUDED #define CATCH_ESTIMATE_HPP_INCLUDED +#include + namespace Catch { namespace Benchmark { - template - struct Estimate { + template struct CATCH_DLL_PUBLIC Estimate { Duration point; Duration lower_bound; Duration upper_bound; diff --git a/src/catch2/benchmark/catch_execution_plan.hpp b/src/catch2/benchmark/catch_execution_plan.hpp index bcb366ce6a..a5ed998097 100644 --- a/src/catch2/benchmark/catch_execution_plan.hpp +++ b/src/catch2/benchmark/catch_execution_plan.hpp @@ -10,20 +10,19 @@ #ifndef CATCH_EXECUTION_PLAN_HPP_INCLUDED #define CATCH_EXECUTION_PLAN_HPP_INCLUDED -#include +#include #include #include #include #include #include - -#include +#include +#include #include namespace Catch { namespace Benchmark { - template - struct ExecutionPlan { + template struct CATCH_DLL_PUBLIC ExecutionPlan { int iterations_per_sample; Duration estimated_duration; Detail::BenchmarkFunction benchmark; diff --git a/src/catch2/benchmark/catch_optimizer.hpp b/src/catch2/benchmark/catch_optimizer.hpp index b9af3ea1de..6d7bae665f 100644 --- a/src/catch2/benchmark/catch_optimizer.hpp +++ b/src/catch2/benchmark/catch_optimizer.hpp @@ -14,8 +14,8 @@ # include // atomic_thread_fence #endif +#include #include - #include namespace Catch { diff --git a/src/catch2/benchmark/catch_outlier_classification.hpp b/src/catch2/benchmark/catch_outlier_classification.hpp index 933f045997..262639e93b 100644 --- a/src/catch2/benchmark/catch_outlier_classification.hpp +++ b/src/catch2/benchmark/catch_outlier_classification.hpp @@ -10,9 +10,11 @@ #ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED #define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED +#include + namespace Catch { namespace Benchmark { - struct OutlierClassification { + struct CATCH_DLL_PUBLIC OutlierClassification { int samples_seen = 0; int low_severe = 0; // more than 3 times IQR below Q1 int low_mild = 0; // 1.5 to 3 times IQR below Q1 diff --git a/src/catch2/benchmark/catch_sample_analysis.hpp b/src/catch2/benchmark/catch_sample_analysis.hpp index 6204aaf141..888ab40e66 100644 --- a/src/catch2/benchmark/catch_sample_analysis.hpp +++ b/src/catch2/benchmark/catch_sample_analysis.hpp @@ -10,19 +10,18 @@ #ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED #define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED +#include #include #include #include +#include #include - -#include -#include #include +#include namespace Catch { namespace Benchmark { - template - struct SampleAnalysis { + template struct CATCH_DLL_PUBLIC SampleAnalysis { std::vector samples; Estimate mean; Estimate standard_deviation; diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.hpp b/src/catch2/benchmark/detail/catch_benchmark_function.hpp index 655c863508..4a3727665e 100644 --- a/src/catch2/benchmark/detail/catch_benchmark_function.hpp +++ b/src/catch2/benchmark/detail/catch_benchmark_function.hpp @@ -12,10 +12,10 @@ #include #include +#include #include -#include #include - +#include #include namespace Catch { @@ -32,7 +32,7 @@ namespace Catch { /// small buffer optimizations, are not uncommon. /// This is effectively an implementation of std::function without any such optimizations; /// it may be slow, but it is consistently slow. - struct BenchmarkFunction { + struct CATCH_DLL_PUBLIC BenchmarkFunction { private: struct callable { virtual void call(Chronometer meter) const = 0; diff --git a/src/catch2/benchmark/detail/catch_run_for_at_least.hpp b/src/catch2/benchmark/detail/catch_run_for_at_least.hpp index 6b2f56e77b..5e363a7408 100644 --- a/src/catch2/benchmark/detail/catch_run_for_at_least.hpp +++ b/src/catch2/benchmark/detail/catch_run_for_at_least.hpp @@ -38,9 +38,7 @@ namespace Catch { template using run_for_at_least_argument_t = std::conditional_t::value, Chronometer, int>; - - [[noreturn]] - void throw_optimized_away_error(); + [[noreturn]] CATCH_DLL_PUBLIC void throw_optimized_away_error(); template TimingOf> diff --git a/src/catch2/benchmark/detail/catch_stats.hpp b/src/catch2/benchmark/detail/catch_stats.hpp index 93c4fd60b1..991b0d911c 100644 --- a/src/catch2/benchmark/detail/catch_stats.hpp +++ b/src/catch2/benchmark/detail/catch_stats.hpp @@ -10,21 +10,25 @@ #ifndef CATCH_STATS_HPP_INCLUDED #define CATCH_STATS_HPP_INCLUDED +#include #include #include - -#include -#include +#include +#include #include #include -#include +#include namespace Catch { namespace Benchmark { namespace Detail { using sample = std::vector; - double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last); + CATCH_DLL_PUBLIC double + weighted_average_quantile( int k, + int q, + std::vector::iterator first, + std::vector::iterator last ); template OutlierClassification classify_outliers(Iterator first, Iterator last) { @@ -77,9 +81,9 @@ namespace Catch { return std::erfc(-x / std::sqrt(2.0)) / 2.0; } - double erfc_inv(double x); + CATCH_DLL_PUBLIC double erfc_inv( double x ); - double normal_quantile(double p); + CATCH_DLL_PUBLIC double normal_quantile( double p ); template Estimate bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) { @@ -130,7 +134,11 @@ namespace Catch { double outlier_variance; }; - bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector::iterator first, std::vector::iterator last); + CATCH_DLL_PUBLIC bootstrap_analysis + analyse_samples( double confidence_level, + unsigned int n_resamples, + std::vector::iterator first, + std::vector::iterator last ); } // namespace Detail } // namespace Benchmark } // namespace Catch diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 92cdc205da..57e21e2b4c 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_approx.hpp b/src/catch2/catch_approx.hpp index a46caeb53b..e52bb924b0 100644 --- a/src/catch2/catch_approx.hpp +++ b/src/catch2/catch_approx.hpp @@ -9,12 +9,12 @@ #define CATCH_APPROX_HPP_INCLUDED #include - +#include #include namespace Catch { - class Approx { + class CATCH_DLL_PUBLIC Approx { private: bool equalityComparisonImpl(double other) const; // Sets and validates the new margin (margin >= 0) @@ -114,8 +114,8 @@ namespace Catch { }; namespace literals { - Approx operator ""_a(long double val); - Approx operator ""_a(unsigned long long val); + CATCH_DLL_PUBLIC Approx operator""_a( long double val ); + CATCH_DLL_PUBLIC Approx operator""_a( unsigned long long val ); } // end namespace literals template<> diff --git a/src/catch2/catch_assertion_info.hpp b/src/catch2/catch_assertion_info.hpp index 516c324c5c..651e274f05 100644 --- a/src/catch2/catch_assertion_info.hpp +++ b/src/catch2/catch_assertion_info.hpp @@ -8,13 +8,14 @@ #ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED #define CATCH_ASSERTION_INFO_HPP_INCLUDED +#include #include #include #include namespace Catch { - struct AssertionInfo { + struct CATCH_DLL_PUBLIC AssertionInfo { // AssertionInfo() = delete; StringRef macroName; diff --git a/src/catch2/catch_assertion_result.hpp b/src/catch2/catch_assertion_result.hpp index 3008664c21..8b0c08d592 100644 --- a/src/catch2/catch_assertion_result.hpp +++ b/src/catch2/catch_assertion_result.hpp @@ -9,17 +9,16 @@ #define CATCH_ASSERTION_RESULT_HPP_INCLUDED #include +#include +#include #include #include #include -#include - #include namespace Catch { - struct AssertionResultData - { + struct CATCH_DLL_PUBLIC AssertionResultData { AssertionResultData() = delete; AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); @@ -32,7 +31,7 @@ namespace Catch { std::string reconstructExpression() const; }; - class AssertionResult { + class CATCH_DLL_PUBLIC AssertionResult { public: AssertionResult() = delete; AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp index 2a71537d28..8771eaf858 100644 --- a/src/catch2/catch_config.hpp +++ b/src/catch2/catch_config.hpp @@ -11,29 +11,32 @@ #include #include #include -#include +#include #include #include - +#include #include -#include #include +#include namespace Catch { class IStream; - struct ConfigData { - struct ReporterAndFile { + struct CATCH_DLL_PUBLIC ConfigData { + struct CATCH_DLL_PUBLIC ReporterAndFile { std::string reporterName; // If none, the output goes to the default output. Optional outputFileName; - friend bool operator==(ReporterAndFile const& lhs, ReporterAndFile const& rhs) { + CATCH_DLL_PUBLIC friend bool + operator==( ReporterAndFile const& lhs, + ReporterAndFile const& rhs ) { return lhs.reporterName == rhs.reporterName && lhs.outputFileName == rhs.outputFileName; } - friend std::ostream& operator<<(std::ostream &os, ReporterAndFile const& reporter); + CATCH_DLL_PUBLIC friend std::ostream& + operator<<( std::ostream& os, ReporterAndFile const& reporter ); }; bool listTests = false; @@ -78,8 +81,7 @@ namespace Catch { std::vector sectionsToRun; }; - - class Config : public IConfig { + class CATCH_DLL_PUBLIC Config : public IConfig { public: Config() = default; diff --git a/src/catch2/catch_message.hpp b/src/catch2/catch_message.hpp index 970ba438a4..c1a6ae2244 100644 --- a/src/catch2/catch_message.hpp +++ b/src/catch2/catch_message.hpp @@ -8,13 +8,13 @@ #ifndef CATCH_MESSAGE_HPP_INCLUDED #define CATCH_MESSAGE_HPP_INCLUDED +#include +#include +#include +#include #include #include #include -#include -#include -#include - #include #include @@ -22,7 +22,7 @@ namespace Catch { struct SourceLineInfo; - struct MessageStream { + struct CATCH_DLL_PUBLIC MessageStream { template MessageStream& operator << ( T const& value ) { @@ -33,7 +33,7 @@ namespace Catch { ReusableStringStream m_stream; }; - struct MessageBuilder : MessageStream { + struct CATCH_DLL_PUBLIC MessageBuilder : MessageStream { MessageBuilder( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType type ): @@ -49,7 +49,7 @@ namespace Catch { MessageInfo m_info; }; - class ScopedMessage { + class CATCH_DLL_PUBLIC ScopedMessage { public: explicit ScopedMessage( MessageBuilder const& builder ); ScopedMessage( ScopedMessage& duplicate ) = delete; @@ -60,7 +60,7 @@ namespace Catch { bool m_moved = false; }; - class Capturer { + class CATCH_DLL_PUBLIC Capturer { std::vector m_messages; IResultCapture& m_resultCapture = getResultCapture(); size_t m_captured = 0; diff --git a/src/catch2/catch_section_info.hpp b/src/catch2/catch_section_info.hpp index 1d206891d0..3dd40fac0b 100644 --- a/src/catch2/catch_section_info.hpp +++ b/src/catch2/catch_section_info.hpp @@ -8,16 +8,16 @@ #ifndef CATCH_SECTION_INFO_HPP_INCLUDED #define CATCH_SECTION_INFO_HPP_INCLUDED +#include +#include #include #include #include -#include - #include namespace Catch { - struct SectionInfo { + struct CATCH_DLL_PUBLIC SectionInfo { // The last argument is ignored, so that people can write // SECTION("ShortName", "Proper description that is long") and // still use the `-c` flag comfortably. @@ -31,7 +31,7 @@ namespace Catch { SourceLineInfo lineInfo; }; - struct SectionEndInfo { + struct CATCH_DLL_PUBLIC SectionEndInfo { SectionInfo sectionInfo; Counts prevAssertions; double durationInSeconds; diff --git a/src/catch2/catch_session.hpp b/src/catch2/catch_session.hpp index b2d3eb0bce..3292e8efa3 100644 --- a/src/catch2/catch_session.hpp +++ b/src/catch2/catch_session.hpp @@ -8,15 +8,16 @@ #ifndef CATCH_SESSION_HPP_INCLUDED #define CATCH_SESSION_HPP_INCLUDED +#include #include +#include +#include #include -#include #include -#include namespace Catch { - class Session : Detail::NonCopyable { + class CATCH_DLL_PUBLIC Session : Detail::NonCopyable { public: Session(); diff --git a/src/catch2/catch_tag_alias.hpp b/src/catch2/catch_tag_alias.hpp index d566d70cb7..1386a01dfb 100644 --- a/src/catch2/catch_tag_alias.hpp +++ b/src/catch2/catch_tag_alias.hpp @@ -8,13 +8,13 @@ #ifndef CATCH_TAG_ALIAS_HPP_INCLUDED #define CATCH_TAG_ALIAS_HPP_INCLUDED +#include #include - #include namespace Catch { - struct TagAlias { + struct CATCH_DLL_PUBLIC TagAlias { TagAlias(std::string const& _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) diff --git a/src/catch2/catch_tag_alias_autoregistrar.hpp b/src/catch2/catch_tag_alias_autoregistrar.hpp index c742bcd3bc..49018b6797 100644 --- a/src/catch2/catch_tag_alias_autoregistrar.hpp +++ b/src/catch2/catch_tag_alias_autoregistrar.hpp @@ -9,12 +9,13 @@ #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED #include -#include +#include #include +#include namespace Catch { - struct RegistrarForTagAliases { + struct CATCH_DLL_PUBLIC RegistrarForTagAliases { RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); }; diff --git a/src/catch2/catch_test_case_info.hpp b/src/catch2/catch_test_case_info.hpp index 3ea656f663..97110d1b86 100644 --- a/src/catch2/catch_test_case_info.hpp +++ b/src/catch2/catch_test_case_info.hpp @@ -8,13 +8,12 @@ #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED #define CATCH_TEST_CASE_INFO_HPP_INCLUDED -#include +#include #include +#include #include #include #include - - #include #include @@ -32,19 +31,21 @@ namespace Catch { * not a part of tag's representation, so e.g. "[cool-tag]" is represented * as "cool-tag" internally. */ - struct Tag { + struct CATCH_DLL_PUBLIC Tag { constexpr Tag(StringRef original_): original(original_) {} StringRef original; - friend bool operator< ( Tag const& lhs, Tag const& rhs ); - friend bool operator==( Tag const& lhs, Tag const& rhs ); + CATCH_DLL_PUBLIC friend bool operator<( Tag const& lhs, + Tag const& rhs ); + CATCH_DLL_PUBLIC friend bool operator==( Tag const& lhs, + Tag const& rhs ); }; struct ITestInvoker; - enum class TestCaseProperties : uint8_t { + enum class CATCH_DLL_PUBLIC TestCaseProperties : uint8_t { None = 0, IsHidden = 1 << 1, ShouldFail = 1 << 2, @@ -63,7 +64,7 @@ namespace Catch { * * Tags are kept sorted. */ - struct TestCaseInfo : Detail::NonCopyable { + struct CATCH_DLL_PUBLIC TestCaseInfo : Detail::NonCopyable { TestCaseInfo(StringRef _className, NameAndTags const& _tags, @@ -103,7 +104,7 @@ namespace Catch { * Does not own either, and is specifically made to be cheap * to copy around. */ - class TestCaseHandle { + class CATCH_DLL_PUBLIC TestCaseHandle { TestCaseInfo* m_info; ITestInvoker* m_invoker; public: @@ -117,7 +118,7 @@ namespace Catch { TestCaseInfo const& getTestCaseInfo() const; }; - Detail::unique_ptr + CATCH_DLL_PUBLIC Detail::unique_ptr makeTestCaseInfo( StringRef className, NameAndTags const& nameAndTags, SourceLineInfo const& lineInfo ); diff --git a/src/catch2/catch_test_spec.hpp b/src/catch2/catch_test_spec.hpp index 4f444fff9a..5f7a85a293 100644 --- a/src/catch2/catch_test_spec.hpp +++ b/src/catch2/catch_test_spec.hpp @@ -13,9 +13,9 @@ #pragma clang diagnostic ignored "-Wpadded" #endif +#include #include #include - #include #include @@ -25,9 +25,9 @@ namespace Catch { struct TestCaseInfo; class TestCaseHandle; - class TestSpec { + class CATCH_DLL_PUBLIC TestSpec { - class Pattern { + class CATCH_DLL_PUBLIC Pattern { public: explicit Pattern( std::string const& name ); virtual ~Pattern(); @@ -37,7 +37,7 @@ namespace Catch { std::string const m_name; }; - class NamePattern : public Pattern { + class CATCH_DLL_PUBLIC NamePattern : public Pattern { public: explicit NamePattern( std::string const& name, std::string const& filterString ); bool matches( TestCaseInfo const& testCase ) const override; @@ -45,7 +45,7 @@ namespace Catch { WildcardPattern m_wildcardPattern; }; - class TagPattern : public Pattern { + class CATCH_DLL_PUBLIC TagPattern : public Pattern { public: explicit TagPattern( std::string const& tag, std::string const& filterString ); bool matches( TestCaseInfo const& testCase ) const override; @@ -53,7 +53,7 @@ namespace Catch { std::string m_tag; }; - struct Filter { + struct CATCH_DLL_PUBLIC Filter { std::vector> m_required; std::vector> m_forbidden; @@ -62,7 +62,7 @@ namespace Catch { }; public: - struct FilterMatch { + struct CATCH_DLL_PUBLIC FilterMatch { std::string name; std::vector tests; }; diff --git a/src/catch2/catch_timer.hpp b/src/catch2/catch_timer.hpp index 30e8141503..0168961c8a 100644 --- a/src/catch2/catch_timer.hpp +++ b/src/catch2/catch_timer.hpp @@ -8,11 +8,12 @@ #ifndef CATCH_TIMER_HPP_INCLUDED #define CATCH_TIMER_HPP_INCLUDED +#include #include namespace Catch { - class Timer { + class CATCH_DLL_PUBLIC Timer { uint64_t m_nanoseconds = 0; public: void start(); diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp index 9182a119fe..e6a389959c 100644 --- a/src/catch2/catch_tostring.hpp +++ b/src/catch2/catch_tostring.hpp @@ -8,18 +8,17 @@ #ifndef CATCH_TOSTRING_HPP_INCLUDED #define CATCH_TOSTRING_HPP_INCLUDED - -#include -#include -#include -#include -#include - +#include #include #include +#include #include #include -#include +#include +#include +#include +#include +#include #ifdef CATCH_CONFIG_CPP17_STRING_VIEW #include @@ -31,8 +30,9 @@ #endif // We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy{}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); +struct CATCH_DLL_PUBLIC Catch_global_namespace_dummy {}; +CATCH_DLL_PUBLIC std::ostream& operator<<( std::ostream&, + Catch_global_namespace_dummy ); namespace Catch { // Bring in global namespace operator<< for ADL lookup in @@ -45,21 +45,22 @@ namespace Catch { constexpr StringRef unprintableString = "{?}"_sr; //! Encases `string in quotes, and optionally escapes invisibles - std::string convertIntoString( StringRef string, bool escapeInvisibles ); + CATCH_DLL_PUBLIC std::string convertIntoString( StringRef string, + bool escapeInvisibles ); //! Encases `string` in quotes, and escapes invisibles if user requested //! it via CLI - std::string convertIntoString( StringRef string ); + CATCH_DLL_PUBLIC std::string convertIntoString( StringRef string ); - std::string rawMemoryToString( const void *object, std::size_t size ); + CATCH_DLL_PUBLIC std::string rawMemoryToString( const void* object, + std::size_t size ); template std::string rawMemoryToString( const T& object ) { return rawMemoryToString( &object, sizeof(object) ); } - template - class IsStreamInsertable { + template class CATCH_DLL_PUBLIC IsStreamInsertable { template static auto test(int) -> decltype(std::declval() << std::declval(), std::true_type()); @@ -111,8 +112,7 @@ namespace Catch { // If we decide for C++14, change these to enable_if_ts - template - struct StringMaker { + template struct CATCH_DLL_PUBLIC StringMaker { template static std::enable_if_t<::Catch::Detail::IsStreamInsertable::value, std::string> @@ -405,12 +405,10 @@ namespace Catch { #include namespace Catch { namespace Detail { - template< - typename Tuple, - std::size_t N = 0, - bool = (N < std::tuple_size::value) - > - struct TupleElementPrinter { + template ::value )> + struct CATCH_DLL_PUBLIC TupleElementPrinter { static void print(const Tuple& tuple, std::ostream& os) { os << (N ? ", " : " ") << ::Catch::Detail::stringify(std::get(tuple)); @@ -477,14 +475,14 @@ namespace Catch { namespace Detail { template - struct is_range_impl : std::false_type {}; + struct CATCH_DLL_PUBLIC is_range_impl : std::false_type {}; template struct is_range_impl()))>> : std::true_type {}; } // namespace Detail template - struct is_range : Detail::is_range_impl {}; + struct CATCH_DLL_PUBLIC is_range : Detail::is_range_impl {}; #if defined(_MANAGED) // Managed types are never ranges template @@ -540,15 +538,13 @@ namespace Catch { namespace Catch { -template -struct ratio_string { - static std::string symbol() { - Catch::ReusableStringStream rss; - rss << '[' << Ratio::num << '/' - << Ratio::den << ']'; - return rss.str(); - } -}; + template struct CATCH_DLL_PUBLIC ratio_string { + static std::string symbol() { + Catch::ReusableStringStream rss; + rss << '[' << Ratio::num << '/' << Ratio::den << ']'; + return rss.str(); + } + }; template <> struct ratio_string { diff --git a/src/catch2/catch_totals.hpp b/src/catch2/catch_totals.hpp index 7ab6a1b611..16c4361a12 100644 --- a/src/catch2/catch_totals.hpp +++ b/src/catch2/catch_totals.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_TOTALS_HPP_INCLUDED #define CATCH_TOTALS_HPP_INCLUDED +#include #include #include namespace Catch { - struct Counts { + struct CATCH_DLL_PUBLIC Counts { Counts operator - ( Counts const& other ) const; Counts& operator += ( Counts const& other ); @@ -26,7 +27,7 @@ namespace Catch { std::uint64_t failedButOk = 0; }; - struct Totals { + struct CATCH_DLL_PUBLIC Totals { Totals operator - ( Totals const& other ) const; Totals& operator += ( Totals const& other ); diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp index dfd95cd696..f29d9b36a0 100644 --- a/src/catch2/catch_translate_exception.hpp +++ b/src/catch2/catch_translate_exception.hpp @@ -10,15 +10,16 @@ #include #include +#include #include - #include namespace Catch { - class ExceptionTranslatorRegistrar { - template - class ExceptionTranslator : public IExceptionTranslator { + class CATCH_DLL_PUBLIC ExceptionTranslatorRegistrar { + template + class CATCH_DLL_PUBLIC ExceptionTranslator + : public IExceptionTranslator { public: ExceptionTranslator( std::string(*translateFunction)( T const& ) ) diff --git a/src/catch2/catch_version.hpp b/src/catch2/catch_version.hpp index 1f64d16376..55106cb5aa 100644 --- a/src/catch2/catch_version.hpp +++ b/src/catch2/catch_version.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_VERSION_HPP_INCLUDED #define CATCH_VERSION_HPP_INCLUDED +#include #include namespace Catch { // Versioning information - struct Version { + struct CATCH_DLL_PUBLIC Version { Version( Version const& ) = delete; Version& operator=( Version const& ) = delete; Version( unsigned int _majorVersion, @@ -30,7 +31,8 @@ namespace Catch { char const * const branchName; unsigned int const buildNumber; - friend std::ostream& operator << ( std::ostream& os, Version const& version ); + CATCH_DLL_PUBLIC friend std::ostream& + operator<<( std::ostream& os, Version const& version ); }; Version const& libraryVersion(); diff --git a/src/catch2/generators/catch_generator_exception.hpp b/src/catch2/generators/catch_generator_exception.hpp index a049452cd2..34b4006a61 100644 --- a/src/catch2/generators/catch_generator_exception.hpp +++ b/src/catch2/generators/catch_generator_exception.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED #define CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED +#include #include namespace Catch { @@ -15,7 +16,7 @@ namespace Catch { // Exception type to be thrown when a Generator runs into an error, // e.g. it cannot initialize the first return value based on // runtime information - class GeneratorException : public std::exception { + class CATCH_DLL_PUBLIC GeneratorException : public std::exception { const char* const m_msg = ""; public: diff --git a/src/catch2/generators/catch_generators.hpp b/src/catch2/generators/catch_generators.hpp index 9ffb9b76d7..2d244ece11 100644 --- a/src/catch2/generators/catch_generators.hpp +++ b/src/catch2/generators/catch_generators.hpp @@ -9,12 +9,12 @@ #define CATCH_GENERATORS_HPP_INCLUDED #include +#include +#include #include #include -#include - -#include #include +#include namespace Catch { @@ -23,32 +23,30 @@ namespace Generators { namespace Detail { //! Throws GeneratorException with the provided message - [[noreturn]] - void throw_generator_exception(char const * msg); + [[noreturn]] void CATCH_DLL_PUBLIC + throw_generator_exception( char const* msg ); } // end namespace detail - template - struct IGenerator : GeneratorUntypedBase { - ~IGenerator() override = default; - IGenerator() = default; - IGenerator(IGenerator const&) = default; - IGenerator& operator=(IGenerator const&) = default; - - - // Returns the current element of the generator - // - // \Precondition The generator is either freshly constructed, - // or the last call to `next()` returned true - virtual T const& get() const = 0; - using type = T; - }; +template +struct CATCH_DLL_PUBLIC IGenerator : GeneratorUntypedBase { + ~IGenerator() override = default; + IGenerator() = default; + IGenerator( IGenerator const& ) = default; + IGenerator& operator=( IGenerator const& ) = default; + + // Returns the current element of the generator + // + // \Precondition The generator is either freshly constructed, + // or the last call to `next()` returned true + virtual T const& get() const = 0; + using type = T; +}; template using GeneratorPtr = Catch::Detail::unique_ptr>; - template - class GeneratorWrapper final { + template class CATCH_DLL_PUBLIC GeneratorWrapper final { GeneratorPtr m_generator; public: //! Takes ownership of the passed pointer. @@ -65,9 +63,8 @@ namespace Detail { } }; - - template - class SingleValueGenerator final : public IGenerator { + template + class CATCH_DLL_PUBLIC SingleValueGenerator final : public IGenerator { T m_value; public: SingleValueGenerator(T const& value) : @@ -85,8 +82,8 @@ namespace Detail { } }; - template - class FixedValuesGenerator final : public IGenerator { + template + class CATCH_DLL_PUBLIC FixedValuesGenerator final : public IGenerator { static_assert(!std::is_same::value, "FixedValuesGenerator does not support bools because of std::vector" "specialization, use SingleValue Generator instead."); @@ -115,8 +112,8 @@ namespace Detail { return GeneratorWrapper(Catch::Detail::make_unique>(values)); } - template - class Generators : public IGenerator { + template + class CATCH_DLL_PUBLIC Generators : public IGenerator { std::vector> m_generators; size_t m_current = 0; @@ -168,7 +165,6 @@ namespace Detail { } }; - template GeneratorWrapper...>> table( std::initializer_list...>> tuples ) { @@ -176,8 +172,7 @@ namespace Detail { } // Tag type to signal that a generator sequence should convert arguments to a specific type - template - struct as {}; + template struct CATCH_DLL_PUBLIC as {}; template auto makeGenerators( GeneratorWrapper&& generator, Gs &&... moreGenerators ) -> Generators { @@ -196,7 +191,9 @@ namespace Detail { return makeGenerators( value( T( CATCH_FORWARD( val ) ) ), CATCH_FORWARD( moreGenerators )... ); } - auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; + auto CATCH_DLL_PUBLIC acquireGeneratorTracker( + StringRef generatorName, SourceLineInfo const& lineInfo ) + -> IGeneratorTracker&; template // Note: The type after -> is weird, because VS2015 cannot parse diff --git a/src/catch2/generators/catch_generators_adapters.hpp b/src/catch2/generators/catch_generators_adapters.hpp index c55a396253..b1e5a4a50c 100644 --- a/src/catch2/generators/catch_generators_adapters.hpp +++ b/src/catch2/generators/catch_generators_adapters.hpp @@ -8,17 +8,17 @@ #ifndef CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED #define CATCH_GENERATORS_ADAPTERS_HPP_INCLUDED +#include #include +#include #include #include -#include - namespace Catch { namespace Generators { template - class TakeGenerator final : public IGenerator { + class CATCH_DLL_PUBLIC TakeGenerator final : public IGenerator { GeneratorWrapper m_generator; size_t m_returned = 0; size_t m_target; @@ -53,9 +53,8 @@ namespace Generators { return GeneratorWrapper(Catch::Detail::make_unique>(target, CATCH_MOVE(generator))); } - template - class FilterGenerator final : public IGenerator { + class CATCH_DLL_PUBLIC FilterGenerator final : public IGenerator { GeneratorWrapper m_generator; Predicate m_predicate; public: @@ -88,14 +87,13 @@ namespace Generators { } }; - template GeneratorWrapper filter(Predicate&& pred, GeneratorWrapper&& generator) { return GeneratorWrapper(Catch::Detail::make_unique>(CATCH_FORWARD(pred), CATCH_MOVE(generator))); } template - class RepeatGenerator final : public IGenerator { + class CATCH_DLL_PUBLIC RepeatGenerator final : public IGenerator { static_assert(!std::is_same::value, "RepeatGenerator currently does not support bools" "because of std::vector specialization"); @@ -151,7 +149,7 @@ namespace Generators { } template - class MapGenerator final : public IGenerator { + class CATCH_DLL_PUBLIC MapGenerator final : public IGenerator { // TBD: provide static assert for mapping function, for friendly error message GeneratorWrapper m_generator; Func m_function; @@ -192,7 +190,8 @@ namespace Generators { } template - class ChunkGenerator final : public IGenerator> { + class CATCH_DLL_PUBLIC ChunkGenerator final + : public IGenerator> { std::vector m_chunk; size_t m_chunk_size; GeneratorWrapper m_generator; diff --git a/src/catch2/generators/catch_generators_random.hpp b/src/catch2/generators/catch_generators_random.hpp index cc66f90805..5ff0b4b964 100644 --- a/src/catch2/generators/catch_generators_random.hpp +++ b/src/catch2/generators/catch_generators_random.hpp @@ -8,58 +8,54 @@ #ifndef CATCH_GENERATORS_RANDOM_HPP_INCLUDED #define CATCH_GENERATORS_RANDOM_HPP_INCLUDED -#include #include +#include +#include #include - #include namespace Catch { namespace Generators { -template -class RandomFloatingGenerator final : public IGenerator { - Catch::SimplePcg32& m_rng; - std::uniform_real_distribution m_dist; - Float m_current_number; -public: - - RandomFloatingGenerator(Float a, Float b): - m_rng(rng()), - m_dist(a, b) { - static_cast(next()); - } - - Float const& get() const override { - return m_current_number; - } - bool next() override { - m_current_number = m_dist(m_rng); - return true; - } -}; - -template -class RandomIntegerGenerator final : public IGenerator { - Catch::SimplePcg32& m_rng; - std::uniform_int_distribution m_dist; - Integer m_current_number; -public: - - RandomIntegerGenerator(Integer a, Integer b): - m_rng(rng()), - m_dist(a, b) { - static_cast(next()); - } - - Integer const& get() const override { - return m_current_number; - } - bool next() override { - m_current_number = m_dist(m_rng); - return true; - } -}; + template + class CATCH_DLL_PUBLIC RandomFloatingGenerator final + : public IGenerator { + Catch::SimplePcg32& m_rng; + std::uniform_real_distribution m_dist; + Float m_current_number; + + public: + RandomFloatingGenerator( Float a, Float b ): + m_rng( rng() ), m_dist( a, b ) { + static_cast( next() ); + } + + Float const& get() const override { return m_current_number; } + bool next() override { + m_current_number = m_dist( m_rng ); + return true; + } + }; + + template + class CATCH_DLL_PUBLIC RandomIntegerGenerator final + : public IGenerator { + Catch::SimplePcg32& m_rng; + std::uniform_int_distribution m_dist; + Integer m_current_number; + + public: + RandomIntegerGenerator( Integer a, Integer b ): + m_rng( rng() ), m_dist( a, b ) { + static_cast( next() ); + } + + Integer const& get() const override { return m_current_number; } + bool next() override { + m_current_number = m_dist( m_rng ); + return true; + } + }; // TODO: Ideally this would be also constrained against the various char types, // but I don't expect users to run into that in practice. diff --git a/src/catch2/generators/catch_generators_range.hpp b/src/catch2/generators/catch_generators_range.hpp index 054af15d54..c836479940 100644 --- a/src/catch2/generators/catch_generators_range.hpp +++ b/src/catch2/generators/catch_generators_range.hpp @@ -9,46 +9,45 @@ #define CATCH_GENERATORS_RANGE_HPP_INCLUDED #include - +#include #include #include namespace Catch { namespace Generators { + template + class CATCH_DLL_PUBLIC RangeGenerator final : public IGenerator { + T m_current; + T m_end; + T m_step; + bool m_positive; + + public: + RangeGenerator( T const& start, T const& end, T const& step ): + m_current( start ), + m_end( end ), + m_step( step ), + m_positive( m_step > T( 0 ) ) { + assert( m_current != m_end && + "Range start and end cannot be equal" ); + assert( m_step != T( 0 ) && "Step size cannot be zero" ); + assert( ( ( m_positive && m_current <= m_end ) || + ( !m_positive && m_current >= m_end ) ) && + "Step moves away from end" ); + } -template -class RangeGenerator final : public IGenerator { - T m_current; - T m_end; - T m_step; - bool m_positive; - -public: - RangeGenerator(T const& start, T const& end, T const& step): - m_current(start), - m_end(end), - m_step(step), - m_positive(m_step > T(0)) - { - assert(m_current != m_end && "Range start and end cannot be equal"); - assert(m_step != T(0) && "Step size cannot be zero"); - assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) && "Step moves away from end"); - } - - RangeGenerator(T const& start, T const& end): - RangeGenerator(start, end, (start < end) ? T(1) : T(-1)) - {} + RangeGenerator( T const& start, T const& end ): + RangeGenerator( start, end, ( start < end ) ? T( 1 ) : T( -1 ) ) {} - T const& get() const override { - return m_current; - } + T const& get() const override { return m_current; } - bool next() override { - m_current += m_step; - return (m_positive) ? (m_current < m_end) : (m_current > m_end); - } -}; + bool next() override { + m_current += m_step; + return ( m_positive ) ? ( m_current < m_end ) + : ( m_current > m_end ); + } + }; template GeneratorWrapper range(T const& start, T const& end, T const& step) { @@ -62,9 +61,8 @@ GeneratorWrapper range(T const& start, T const& end) { return GeneratorWrapper(Catch::Detail::make_unique>(start, end)); } - template -class IteratorGenerator final : public IGenerator { +class CATCH_DLL_PUBLIC IteratorGenerator final : public IGenerator { static_assert(!std::is_same::value, "IteratorGenerator currently does not support bools" "because of std::vector specialization"); diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp index 2e7a631f15..e1745df5bc 100644 --- a/src/catch2/interfaces/catch_interfaces_capture.hpp +++ b/src/catch2/interfaces/catch_interfaces_capture.hpp @@ -8,11 +8,11 @@ #ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED #define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED -#include -#include - -#include +#include #include +#include +#include +#include namespace Catch { @@ -33,7 +33,7 @@ namespace Catch { template > struct BenchmarkStats; - struct IResultCapture { + struct CATCH_DLL_PUBLIC IResultCapture { virtual ~IResultCapture(); @@ -90,7 +90,7 @@ namespace Catch { virtual void exceptionEarlyReported() = 0; }; - IResultCapture& getResultCapture(); + CATCH_DLL_PUBLIC IResultCapture& getResultCapture(); } #endif // CATCH_INTERFACES_CAPTURE_HPP_INCLUDED diff --git a/src/catch2/interfaces/catch_interfaces_config.hpp b/src/catch2/interfaces/catch_interfaces_config.hpp index d98f7b4411..4d63a95dfc 100644 --- a/src/catch2/interfaces/catch_interfaces_config.hpp +++ b/src/catch2/interfaces/catch_interfaces_config.hpp @@ -8,9 +8,9 @@ #ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED #define CATCH_INTERFACES_CONFIG_HPP_INCLUDED +#include #include #include - #include #include #include @@ -18,46 +18,42 @@ namespace Catch { - enum class Verbosity { - Quiet = 0, - Normal, - High - }; + enum class CATCH_DLL_PUBLIC Verbosity { Quiet = 0, Normal, High }; - struct WarnAbout { enum What { - Nothing = 0x00, - //! A test case or leaf section did not run any assertions - NoAssertions = 0x01, - //! A command line test spec matched no test cases - UnmatchedTestSpec = 0x02, - }; }; + struct CATCH_DLL_PUBLIC WarnAbout { + enum What { + Nothing = 0x00, + //! A test case or leaf section did not run any assertions + NoAssertions = 0x01, + //! A command line test spec matched no test cases + UnmatchedTestSpec = 0x02, + }; + }; - enum class ShowDurations { + enum class CATCH_DLL_PUBLIC ShowDurations { DefaultForReporter, Always, Never }; - enum class TestRunOrder { + enum class CATCH_DLL_PUBLIC TestRunOrder { Declared, LexicographicallySorted, Randomized }; - enum class UseColour { - Auto, - Yes, - No + enum class CATCH_DLL_PUBLIC UseColour { Auto, Yes, No }; + struct CATCH_DLL_PUBLIC WaitForKeypress { + enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; - struct WaitForKeypress { enum When { - Never, - BeforeStart = 1, - BeforeExit = 2, - BeforeStartAndExit = BeforeStart | BeforeExit - }; }; class TestSpec; class IStream; - struct IConfig : Detail::NonCopyable { + struct CATCH_DLL_PUBLIC IConfig : Detail::NonCopyable { virtual ~IConfig(); diff --git a/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp b/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp index e00f2c9db5..30341924af 100644 --- a/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp +++ b/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp @@ -8,14 +8,14 @@ #ifndef CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED #define CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED +#include #include - #include namespace Catch { namespace Detail { - struct EnumInfo { + struct CATCH_DLL_PUBLIC EnumInfo { StringRef m_name; std::vector> m_values; @@ -25,7 +25,7 @@ namespace Catch { }; } // namespace Detail - struct IMutableEnumValuesRegistry { + struct CATCH_DLL_PUBLIC IMutableEnumValuesRegistry { virtual ~IMutableEnumValuesRegistry(); // = default; virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values ) = 0; diff --git a/src/catch2/interfaces/catch_interfaces_exception.hpp b/src/catch2/interfaces/catch_interfaces_exception.hpp index c183407457..bc221b8f84 100644 --- a/src/catch2/interfaces/catch_interfaces_exception.hpp +++ b/src/catch2/interfaces/catch_interfaces_exception.hpp @@ -9,8 +9,8 @@ #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED #include +#include #include - #include #include @@ -20,12 +20,12 @@ namespace Catch { struct IExceptionTranslator; using ExceptionTranslators = std::vector>; - struct IExceptionTranslator { + struct CATCH_DLL_PUBLIC IExceptionTranslator { virtual ~IExceptionTranslator(); // = default virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; }; - struct IExceptionTranslatorRegistry { + struct CATCH_DLL_PUBLIC IExceptionTranslatorRegistry { virtual ~IExceptionTranslatorRegistry(); // = default virtual std::string translateActiveException() const = 0; diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp index f1ca34417a..99b9f72c00 100644 --- a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp +++ b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED #define CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED +#include #include namespace Catch { namespace Generators { - class GeneratorUntypedBase { + class CATCH_DLL_PUBLIC GeneratorUntypedBase { public: GeneratorUntypedBase() = default; // Generation of copy ops is deprecated (and Clang will complain) @@ -33,7 +34,7 @@ namespace Catch { } // namespace Generators - struct IGeneratorTracker { + struct CATCH_DLL_PUBLIC IGeneratorTracker { virtual ~IGeneratorTracker(); // = default; virtual auto hasGenerator() const -> bool = 0; virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0; diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp index 1c40f2de2c..f1fed3568b 100644 --- a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp +++ b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp @@ -8,8 +8,8 @@ #ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED #define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED +#include #include - #include namespace Catch { @@ -31,7 +31,7 @@ namespace Catch { using IReporterFactoryPtr = Detail::unique_ptr; - struct IRegistryHub { + struct CATCH_DLL_PUBLIC IRegistryHub { virtual ~IRegistryHub(); // = default virtual IReporterRegistry const& getReporterRegistry() const = 0; @@ -43,7 +43,7 @@ namespace Catch { virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; }; - struct IMutableRegistryHub { + struct CATCH_DLL_PUBLIC IMutableRegistryHub { virtual ~IMutableRegistryHub(); // = default virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0; virtual void registerListener( Detail::unique_ptr factory ) = 0; @@ -54,11 +54,10 @@ namespace Catch { virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; }; - IRegistryHub const& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); - + CATCH_DLL_PUBLIC IRegistryHub const& getRegistryHub(); + CATCH_DLL_PUBLIC IMutableRegistryHub& getMutableRegistryHub(); + CATCH_DLL_PUBLIC void cleanUp(); + CATCH_DLL_PUBLIC std::string translateActiveException(); } #endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp index 53d5ae60b9..ae787e3b82 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp @@ -8,20 +8,19 @@ #ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED #define CATCH_INTERFACES_REPORTER_HPP_INCLUDED +#include +#include +#include #include #include -#include +#include #include +#include #include #include -#include -#include -#include - - +#include #include #include -#include namespace Catch { @@ -32,7 +31,7 @@ namespace Catch { struct IConfig; class IStream; - struct ReporterConfig { + struct CATCH_DLL_PUBLIC ReporterConfig { ReporterConfig( IConfig const* _fullConfig, IStream const* _stream ); IStream const* stream() const; @@ -43,12 +42,12 @@ namespace Catch { IConfig const* m_fullConfig; }; - struct TestRunInfo { + struct CATCH_DLL_PUBLIC TestRunInfo { constexpr TestRunInfo(StringRef _name) : name(_name) {} StringRef name; }; - struct AssertionStats { + struct CATCH_DLL_PUBLIC AssertionStats { AssertionStats( AssertionResult const& _assertionResult, std::vector const& _infoMessages, Totals const& _totals ); @@ -63,7 +62,7 @@ namespace Catch { Totals totals; }; - struct SectionStats { + struct CATCH_DLL_PUBLIC SectionStats { SectionStats( SectionInfo const& _sectionInfo, Counts const& _assertions, double _durationInSeconds, @@ -75,7 +74,7 @@ namespace Catch { bool missingAssertions; }; - struct TestCaseStats { + struct CATCH_DLL_PUBLIC TestCaseStats { TestCaseStats( TestCaseInfo const& _testInfo, Totals const& _totals, std::string const& _stdOut, @@ -89,7 +88,7 @@ namespace Catch { bool aborting; }; - struct TestRunStats { + struct CATCH_DLL_PUBLIC TestRunStats { TestRunStats( TestRunInfo const& _runInfo, Totals const& _totals, bool _aborting ); @@ -99,8 +98,7 @@ namespace Catch { bool aborting; }; - - struct BenchmarkInfo { + struct CATCH_DLL_PUBLIC BenchmarkInfo { std::string name; double estimatedDuration; int iterations; @@ -110,8 +108,7 @@ namespace Catch { double clockCost; }; - template - struct BenchmarkStats { + template struct CATCH_DLL_PUBLIC BenchmarkStats { BenchmarkInfo info; std::vector samples; @@ -141,7 +138,7 @@ namespace Catch { //! By setting up its preferences, a reporter can modify Catch2's behaviour //! in some regards, e.g. it can request Catch2 to capture writes to //! stdout/stderr during test execution, and pass them to the reporter. - struct ReporterPreferences { + struct CATCH_DLL_PUBLIC ReporterPreferences { //! Catch2 should redirect writes to stdout and pass them to the //! reporter bool shouldRedirectStdOut = false; @@ -162,7 +159,7 @@ namespace Catch { * instead they should derive from one of the utility bases that * derive from this class. */ - class IEventListener { + class CATCH_DLL_PUBLIC IEventListener { protected: //! Derived classes can set up their preferences here ReporterPreferences m_preferences; @@ -240,7 +237,6 @@ namespace Catch { virtual void listTests(std::vector const& tests) = 0; //! Writes out information about the provided tags using reporter-specific format virtual void listTags(std::vector const& tags) = 0; - }; using IStreamingReporterPtr = Detail::unique_ptr; diff --git a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp index 0f9b90cddf..ecf1dc71c8 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp @@ -8,8 +8,8 @@ #ifndef CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED #define CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED +#include #include - #include namespace Catch { @@ -19,8 +19,7 @@ namespace Catch { class IEventListener; using IStreamingReporterPtr = Detail::unique_ptr; - - struct IReporterFactory { + struct CATCH_DLL_PUBLIC IReporterFactory { virtual ~IReporterFactory(); // = default virtual IStreamingReporterPtr @@ -29,7 +28,7 @@ namespace Catch { }; using IReporterFactoryPtr = Detail::unique_ptr; - class EventListenerFactory { + class CATCH_DLL_PUBLIC EventListenerFactory { public: virtual ~EventListenerFactory(); // = default virtual IStreamingReporterPtr create( IConfig const* config ) const = 0; diff --git a/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp b/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp index 7a7b275d8c..71d5abca01 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp @@ -9,11 +9,11 @@ #define CATCH_INTERFACES_REPORTER_REGISTRY_HPP_INCLUDED #include +#include #include - +#include #include #include -#include namespace Catch { @@ -26,7 +26,7 @@ namespace Catch { struct ReporterConfig; class EventListenerFactory; - struct IReporterRegistry { + struct CATCH_DLL_PUBLIC IReporterRegistry { using FactoryMap = std::map; using Listeners = std::vector>; diff --git a/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp b/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp index 6b0973b402..4064fbcce7 100644 --- a/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp +++ b/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp @@ -8,13 +8,14 @@ #ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED #define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED +#include #include namespace Catch { struct TagAlias; - struct ITagAliasRegistry { + struct CATCH_DLL_PUBLIC ITagAliasRegistry { virtual ~ITagAliasRegistry(); // = default // Nullptr if not present virtual TagAlias const* find( std::string const& alias ) const = 0; diff --git a/src/catch2/interfaces/catch_interfaces_testcase.hpp b/src/catch2/interfaces/catch_interfaces_testcase.hpp index 2d0b6c284f..9287c625b2 100644 --- a/src/catch2/interfaces/catch_interfaces_testcase.hpp +++ b/src/catch2/interfaces/catch_interfaces_testcase.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED #define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED +#include #include namespace Catch { @@ -15,7 +16,7 @@ namespace Catch { class TestSpec; struct TestCaseInfo; - struct ITestInvoker { + struct CATCH_DLL_PUBLIC ITestInvoker { virtual void invoke () const = 0; virtual ~ITestInvoker(); // = default }; @@ -23,7 +24,7 @@ namespace Catch { class TestCaseHandle; struct IConfig; - struct ITestCaseRegistry { + struct CATCH_DLL_PUBLIC ITestCaseRegistry { virtual ~ITestCaseRegistry(); // = default // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later virtual std::vector const& getAllInfos() const = 0; diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index b7c7613e31..066813389f 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -9,8 +9,9 @@ #define CATCH_ASSERTION_HANDLER_HPP_INCLUDED #include -#include #include +#include +#include #include namespace Catch { @@ -19,12 +20,12 @@ namespace Catch { struct IResultCapture; class RunContext; - struct AssertionReaction { + struct CATCH_DLL_PUBLIC AssertionReaction { bool shouldDebugBreak = false; bool shouldThrow = false; }; - class AssertionHandler { + class CATCH_DLL_PUBLIC AssertionHandler { AssertionInfo m_assertionInfo; AssertionReaction m_reaction; bool m_completed = false; @@ -64,7 +65,9 @@ namespace Catch { auto allowThrows() const -> bool; }; - void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ); + CATCH_DLL_PUBLIC void handleExceptionMatchExpr( AssertionHandler& handler, + std::string const& str, + StringRef matcherString ); } // namespace Catch diff --git a/src/catch2/internal/catch_case_insensitive_comparisons.hpp b/src/catch2/internal/catch_case_insensitive_comparisons.hpp index 5742e6b784..aff5cc3fec 100644 --- a/src/catch2/internal/catch_case_insensitive_comparisons.hpp +++ b/src/catch2/internal/catch_case_insensitive_comparisons.hpp @@ -8,20 +8,20 @@ #ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED #define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED +#include #include - #include namespace Catch { namespace Detail { //! Provides case-insensitive `op<` semantics when called - struct CaseInsensitiveLess { + struct CATCH_DLL_PUBLIC CaseInsensitiveLess { bool operator()( StringRef lhs, StringRef rhs ) const; }; //! Provides case-insensitive `op==` semantics when called - struct CaseInsensitiveEqualTo { + struct CATCH_DLL_PUBLIC CaseInsensitiveEqualTo { bool operator()( StringRef lhs, StringRef rhs ) const; }; @@ -29,4 +29,4 @@ namespace Catch { } // namespace Detail } // namespace Catch -#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED \ No newline at end of file +#endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED diff --git a/src/catch2/internal/catch_case_sensitive.hpp b/src/catch2/internal/catch_case_sensitive.hpp index f941d1f2f1..3befe04955 100644 --- a/src/catch2/internal/catch_case_sensitive.hpp +++ b/src/catch2/internal/catch_case_sensitive.hpp @@ -8,9 +8,11 @@ #ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED #define CATCH_CASE_SENSITIVE_HPP_INCLUDED +#include + namespace Catch { - enum class CaseSensitive { Yes, No }; + enum class CATCH_DLL_PUBLIC CaseSensitive { Yes, No }; } // namespace Catch diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 00761c0af6..f16d046389 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -29,11 +29,11 @@ # endif #endif +#include +#include #include #include #include - -#include #include #include #include @@ -49,24 +49,24 @@ namespace Catch { class Parser; // enum of result types from a parse - enum class ParseResultType { + enum class CATCH_DLL_PUBLIC ParseResultType { Matched, NoMatch, ShortCircuitAll, ShortCircuitSame }; - struct accept_many_t {}; + struct CATCH_DLL_PUBLIC accept_many_t {}; constexpr accept_many_t accept_many {}; namespace Detail { - struct fake_arg { + struct CATCH_DLL_PUBLIC fake_arg { template operator T(); }; template - struct is_unary_function : std::false_type {}; + struct CATCH_DLL_PUBLIC is_unary_function : std::false_type {}; template struct is_unary_function< @@ -99,15 +99,15 @@ namespace Catch { // Wraps a token coming from a token stream. These may not directly // correspond to strings as a single string may encode an option + // its argument if the : or = form is used - enum class TokenType { Option, Argument }; - struct Token { + enum class CATCH_DLL_PUBLIC TokenType { Option, Argument }; + struct CATCH_DLL_PUBLIC Token { TokenType type; std::string token; }; // Abstracts iterators into args as a stream of tokens, with option // arguments uniformly handled - class TokenStream { + class CATCH_DLL_PUBLIC TokenStream { using Iterator = std::vector::const_iterator; Iterator it; Iterator itEnd; @@ -141,14 +141,14 @@ namespace Catch { }; //! Denotes type of a parsing result - enum class ResultType { + enum class CATCH_DLL_PUBLIC ResultType { Ok, ///< No errors LogicError, ///< Error in user-specified arguments for ///< construction RuntimeError ///< Error in parsing inputs }; - class ResultBase { + class CATCH_DLL_PUBLIC ResultBase { protected: ResultBase( ResultType type ): m_type( type ) {} virtual ~ResultBase(); // = default; @@ -164,7 +164,8 @@ namespace Catch { ResultType m_type; }; - template class ResultValueBase : public ResultBase { + template + class CATCH_DLL_PUBLIC ResultValueBase : public ResultBase { public: auto value() const -> T const& { enforceOk(); @@ -210,7 +211,7 @@ namespace Catch { }; template - class BasicResult : public ResultValueBase { + class CATCH_DLL_PUBLIC BasicResult : public ResultValueBase { public: template explicit BasicResult( BasicResult const& other ): @@ -265,7 +266,7 @@ namespace Catch { using ResultBase::m_type; }; - class ParseState { + class CATCH_DLL_PUBLIC ParseState { public: ParseState( ParseResultType type, TokenStream const& remainingTokens ); @@ -284,7 +285,7 @@ namespace Catch { using ParserResult = BasicResult; using InternalParseResult = BasicResult; - struct HelpColumns { + struct CATCH_DLL_PUBLIC HelpColumns { std::string left; std::string right; }; @@ -301,9 +302,10 @@ namespace Catch { return ParserResult::ok( ParseResultType::Matched ); } } - ParserResult convertInto( std::string const& source, - std::string& target ); - ParserResult convertInto( std::string const& source, bool& target ); + CATCH_DLL_PUBLIC ParserResult + convertInto( std::string const& source, std::string& target ); + CATCH_DLL_PUBLIC ParserResult + convertInto( std::string const& source, bool& target ); #ifdef CLARA_CONFIG_OPTIONAL_TYPE template @@ -318,21 +320,22 @@ namespace Catch { } #endif // CLARA_CONFIG_OPTIONAL_TYPE - struct BoundRef : Catch::Detail::NonCopyable { + struct CATCH_DLL_PUBLIC BoundRef : Catch::Detail::NonCopyable { virtual ~BoundRef() = default; virtual bool isContainer() const; virtual bool isFlag() const; }; - struct BoundValueRefBase : BoundRef { + struct CATCH_DLL_PUBLIC BoundValueRefBase : BoundRef { virtual auto setValue( std::string const& arg ) -> ParserResult = 0; }; - struct BoundFlagRefBase : BoundRef { + struct CATCH_DLL_PUBLIC BoundFlagRefBase : BoundRef { virtual auto setFlag( bool flag ) -> ParserResult = 0; bool isFlag() const override; }; - template struct BoundValueRef : BoundValueRefBase { + template + struct CATCH_DLL_PUBLIC BoundValueRef : BoundValueRefBase { T& m_ref; explicit BoundValueRef( T& ref ): m_ref( ref ) {} @@ -360,7 +363,7 @@ namespace Catch { } }; - struct BoundFlagRef : BoundFlagRefBase { + struct CATCH_DLL_PUBLIC BoundFlagRef : BoundFlagRefBase { bool& m_ref; explicit BoundFlagRef( bool& ref ): m_ref( ref ) {} @@ -368,7 +371,8 @@ namespace Catch { ParserResult setFlag( bool flag ) override; }; - template struct LambdaInvoker { + template + struct CATCH_DLL_PUBLIC LambdaInvoker { static_assert( std::is_same::value, "Lambda must return void or clara::ParserResult" ); @@ -399,7 +403,8 @@ namespace Catch { L>::ReturnType>::invoke( lambda, temp ); } - template struct BoundLambda : BoundValueRefBase { + template + struct CATCH_DLL_PUBLIC BoundLambda : BoundValueRefBase { L m_lambda; static_assert( @@ -414,12 +419,14 @@ namespace Catch { } }; - template struct BoundManyLambda : BoundLambda { + template + struct CATCH_DLL_PUBLIC BoundManyLambda : BoundLambda { explicit BoundManyLambda( L const& lambda ): BoundLambda( lambda ) {} bool isContainer() const override { return true; } }; - template struct BoundFlagLambda : BoundFlagRefBase { + template + struct CATCH_DLL_PUBLIC BoundFlagLambda : BoundFlagRefBase { L m_lambda; static_assert( @@ -439,9 +446,9 @@ namespace Catch { } }; - enum class Optionality { Optional, Required }; + enum class CATCH_DLL_PUBLIC Optionality { Optional, Required }; - class ParserBase { + class CATCH_DLL_PUBLIC ParserBase { public: virtual ~ParserBase() = default; virtual auto validate() const -> Result { return Result::ok(); } @@ -454,7 +461,7 @@ namespace Catch { }; template - class ComposableParserImpl : public ParserBase { + class CATCH_DLL_PUBLIC ComposableParserImpl : public ParserBase { public: template auto operator|( T const& other ) const -> Parser; @@ -462,7 +469,8 @@ namespace Catch { // Common code and state for Args and Opts template - class ParserRefImpl : public ComposableParserImpl { + class CATCH_DLL_PUBLIC ParserRefImpl + : public ComposableParserImpl { protected: Optionality m_optionality = Optionality::Optional; std::shared_ptr m_ref; @@ -527,7 +535,7 @@ namespace Catch { // A parser for arguments - class Arg : public Detail::ParserRefImpl { + class CATCH_DLL_PUBLIC Arg : public Detail::ParserRefImpl { public: using ParserRefImpl::ParserRefImpl; using ParserBase::parse; @@ -538,7 +546,7 @@ namespace Catch { }; // A parser for options - class Opt : public Detail::ParserRefImpl { + class CATCH_DLL_PUBLIC Opt : public Detail::ParserRefImpl { protected: std::vector m_optNames; @@ -585,7 +593,8 @@ namespace Catch { }; // Specifies the name of the executable - class ExeName : public Detail::ComposableParserImpl { + class CATCH_DLL_PUBLIC ExeName + : public Detail::ComposableParserImpl { std::shared_ptr m_name; std::shared_ptr m_ref; @@ -614,9 +623,8 @@ namespace Catch { Detail::ParserResult set(std::string const& newName); }; - // A Combined parser - class Parser : Detail::ParserBase { + class CATCH_DLL_PUBLIC Parser : Detail::ParserBase { mutable ExeName m_exeName; std::vector m_options; std::vector m_args; @@ -649,7 +657,8 @@ namespace Catch { void writeToStream(std::ostream& os) const; - friend auto operator<<(std::ostream& os, Parser const& parser) + CATCH_DLL_PUBLIC friend auto operator<<( std::ostream& os, + Parser const& parser ) -> std::ostream& { parser.writeToStream(os); return os; @@ -665,7 +674,7 @@ namespace Catch { // Transport for raw args (copied from main args, or supplied via // init list for testing) - class Args { + class CATCH_DLL_PUBLIC Args { friend Detail::TokenStream; std::string m_exeName; std::vector m_args; @@ -677,9 +686,8 @@ namespace Catch { std::string const& exeName() const { return m_exeName; } }; - // Convenience wrapper for option parser that specifies the help option - struct Help : Opt { + struct CATCH_DLL_PUBLIC Help : Opt { Help(bool& showHelpFlag); }; diff --git a/src/catch2/internal/catch_commandline.hpp b/src/catch2/internal/catch_commandline.hpp index 1e03085644..a52b33d60b 100644 --- a/src/catch2/internal/catch_commandline.hpp +++ b/src/catch2/internal/catch_commandline.hpp @@ -14,7 +14,7 @@ namespace Catch { struct ConfigData; - Clara::Parser makeCommandLineParser( ConfigData& config ); + CATCH_DLL_PUBLIC Clara::Parser makeCommandLineParser( ConfigData& config ); } // end namespace Catch diff --git a/src/catch2/internal/catch_console_colour.hpp b/src/catch2/internal/catch_console_colour.hpp index e6a37967f4..653f804cfc 100644 --- a/src/catch2/internal/catch_console_colour.hpp +++ b/src/catch2/internal/catch_console_colour.hpp @@ -8,8 +8,8 @@ #ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED #define CATCH_CONSOLE_COLOUR_HPP_INCLUDED +#include #include - #include namespace Catch { @@ -17,7 +17,7 @@ namespace Catch { struct IConfig; class IStream; - struct Colour { + struct CATCH_DLL_PUBLIC Colour { enum Code { None = 0, @@ -55,20 +55,21 @@ namespace Catch { }; }; - class ColourImpl { + class CATCH_DLL_PUBLIC ColourImpl { protected: //! The associated stream of this ColourImpl instance IStream const* m_stream; public: ColourImpl( IStream const* stream ): m_stream( stream ) {} - class ColourGuard { + class CATCH_DLL_PUBLIC ColourGuard { ColourImpl const* m_colourImpl; bool m_moved = false; - friend std::ostream& operator<<(std::ostream& lhs, - ColourGuard const&) { + CATCH_DLL_PUBLIC friend std::ostream& + operator<<( std::ostream& lhs, ColourGuard const& ) { return lhs; } + public: ColourGuard( Colour::Code code, ColourImpl const* colour ); @@ -87,7 +88,8 @@ namespace Catch { }; //! Provides ColourImpl based on global config and target compilation platform - Detail::unique_ptr makeColourImpl( IConfig const* config, IStream const* stream ); + CATCH_DLL_PUBLIC Detail::unique_ptr + makeColourImpl( IConfig const* config, IStream const* stream ); } // end namespace Catch diff --git a/src/catch2/internal/catch_context.hpp b/src/catch2/internal/catch_context.hpp index d355244822..9255e85797 100644 --- a/src/catch2/internal/catch_context.hpp +++ b/src/catch2/internal/catch_context.hpp @@ -8,21 +8,21 @@ #ifndef CATCH_CONTEXT_HPP_INCLUDED #define CATCH_CONTEXT_HPP_INCLUDED +#include + namespace Catch { struct IResultCapture; struct IConfig; - struct IContext - { + struct CATCH_DLL_PUBLIC IContext { virtual ~IContext(); // = default virtual IResultCapture* getResultCapture() = 0; virtual IConfig const* getConfig() const = 0; }; - struct IMutableContext : IContext - { + struct CATCH_DLL_PUBLIC IMutableContext : IContext { virtual ~IMutableContext(); // = default virtual void setResultCapture( IResultCapture* resultCapture ) = 0; virtual void setConfig( IConfig const* config ) = 0; @@ -49,8 +49,8 @@ namespace Catch { void cleanUpContext(); - class SimplePcg32; - SimplePcg32& rng(); + class CATCH_DLL_PUBLIC SimplePcg32; + CATCH_DLL_PUBLIC SimplePcg32& rng(); } #endif // CATCH_CONTEXT_HPP_INCLUDED diff --git a/src/catch2/internal/catch_debug_console.hpp b/src/catch2/internal/catch_debug_console.hpp index a4b80f09b9..56b3d29f6d 100644 --- a/src/catch2/internal/catch_debug_console.hpp +++ b/src/catch2/internal/catch_debug_console.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_DEBUG_CONSOLE_HPP_INCLUDED #define CATCH_DEBUG_CONSOLE_HPP_INCLUDED +#include #include namespace Catch { diff --git a/src/catch2/internal/catch_debugger.hpp b/src/catch2/internal/catch_debugger.hpp index c300da72cd..42d4689b1b 100644 --- a/src/catch2/internal/catch_debugger.hpp +++ b/src/catch2/internal/catch_debugger.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_DEBUGGER_HPP_INCLUDED #define CATCH_DEBUGGER_HPP_INCLUDED +#include #include namespace Catch { diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index a747c34cd6..8174a96050 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -9,9 +9,9 @@ #define CATCH_DECOMPOSER_HPP_INCLUDED #include -#include +#include #include - +#include #include #ifdef _MSC_VER @@ -33,7 +33,7 @@ namespace Catch { - struct ITransientExpression { + struct CATCH_DLL_PUBLIC ITransientExpression { auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } auto getResult() const -> bool { return m_result; } virtual void streamReconstructedExpression( std::ostream &os ) const = 0; @@ -53,16 +53,21 @@ namespace Catch { bool m_isBinaryExpression; bool m_result; - friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) { + CATCH_DLL_PUBLIC friend std::ostream& + operator<<( std::ostream& out, ITransientExpression const& expr ) { expr.streamReconstructedExpression(out); return out; } }; - void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + CATCH_DLL_PUBLIC void + formatReconstructedExpression( std::ostream& os, + std::string const& lhs, + StringRef op, + std::string const& rhs ); - template - class BinaryExpr : public ITransientExpression { + template + class CATCH_DLL_PUBLIC BinaryExpr : public ITransientExpression { LhsT m_lhs; StringRef m_op; RhsT m_rhs; @@ -137,8 +142,8 @@ namespace Catch { } }; - template - class UnaryExpr : public ITransientExpression { + template + class CATCH_DLL_PUBLIC UnaryExpr : public ITransientExpression { LhsT m_lhs; void streamReconstructedExpression( std::ostream &os ) const override { @@ -152,7 +157,6 @@ namespace Catch { {} }; - // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) template auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast(lhs == rhs); } @@ -176,9 +180,7 @@ namespace Catch { template auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } - - template - class ExprLhs { + template class CATCH_DLL_PUBLIC ExprLhs { LhsT m_lhs; public: explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} @@ -240,7 +242,7 @@ namespace Catch { } }; - struct Decomposer { + struct CATCH_DLL_PUBLIC Decomposer { template>::value, int> = 0> friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs { return ExprLhs{ lhs }; diff --git a/src/catch2/internal/catch_dll_public.hpp b/src/catch2/internal/catch_dll_public.hpp new file mode 100644 index 0000000000..10a96e392c --- /dev/null +++ b/src/catch2/internal/catch_dll_public.hpp @@ -0,0 +1,33 @@ +#ifndef CATCH_CATCH_DLL_PUBLIC +#define CATCH_CATCH_DLL_PUBLIC + +#if defined _WIN32 || defined __CYGWIN__ +# ifdef BUILDING_DLL +# ifdef __GNUC__ +# define CATCH_DLL_PUBLIC __attribute__( ( dllexport ) ) +# else +# define CATCH_DLL_PUBLIC \ + __declspec( dllexport ) // Note: actually gcc seems to also + // supports this syntax. +# endif +# else +# ifdef __GNUC__ +# define CATCH_DLL_PUBLIC __attribute__( ( dllimport ) ) +# else +# define CATCH_DLL_PUBLIC \ + __declspec( dllimport ) // Note: actually gcc seems to also + // supports this syntax. +# endif +# endif +# define DLL_LOCAL +#else +# if __GNUC__ >= 4 +# define CATCH_DLL_PUBLIC __attribute__( ( visibility( "default" ) ) ) +# define DLL_LOCAL __attribute__( ( visibility( "hidden" ) ) ) +# else +# define CATCH_DLL_PUBLIC +# define DLL_LOCAL +# endif +#endif + +#endif // CATCH_CATCH_DLL_PUBLIC diff --git a/src/catch2/internal/catch_enforce.hpp b/src/catch2/internal/catch_enforce.hpp index 3f81ef1a03..724e43a48e 100644 --- a/src/catch2/internal/catch_enforce.hpp +++ b/src/catch2/internal/catch_enforce.hpp @@ -8,10 +8,10 @@ #ifndef CATCH_ENFORCE_HPP_INCLUDED #define CATCH_ENFORCE_HPP_INCLUDED -#include #include +#include +#include #include - #include namespace Catch { @@ -26,12 +26,12 @@ namespace Catch { void throw_exception(std::exception const& e); #endif - [[noreturn]] - void throw_logic_error(std::string const& msg); - [[noreturn]] - void throw_domain_error(std::string const& msg); - [[noreturn]] - void throw_runtime_error(std::string const& msg); + [[noreturn]] CATCH_DLL_PUBLIC void + throw_logic_error( std::string const& msg ); + [[noreturn]] CATCH_DLL_PUBLIC void + throw_domain_error( std::string const& msg ); + [[noreturn]] CATCH_DLL_PUBLIC void + throw_runtime_error( std::string const& msg ); } // namespace Catch; diff --git a/src/catch2/internal/catch_enum_values_registry.hpp b/src/catch2/internal/catch_enum_values_registry.hpp index 0c16a4c15d..788f219a0b 100644 --- a/src/catch2/internal/catch_enum_values_registry.hpp +++ b/src/catch2/internal/catch_enum_values_registry.hpp @@ -9,16 +9,19 @@ #define CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED #include -#include +#include #include - +#include #include namespace Catch { namespace Detail { - Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ); + CATCH_DLL_PUBLIC Catch::Detail::unique_ptr + makeEnumInfo( StringRef enumName, + StringRef allValueNames, + std::vector const& values ); class EnumValuesRegistry : public IMutableEnumValuesRegistry { @@ -27,7 +30,7 @@ namespace Catch { EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values) override; }; - std::vector parseEnums( StringRef enums ); + CATCH_DLL_PUBLIC std::vector parseEnums( StringRef enums ); } // Detail diff --git a/src/catch2/internal/catch_errno_guard.hpp b/src/catch2/internal/catch_errno_guard.hpp index 9082c50855..684aa64a05 100644 --- a/src/catch2/internal/catch_errno_guard.hpp +++ b/src/catch2/internal/catch_errno_guard.hpp @@ -8,11 +8,13 @@ #ifndef CATCH_ERRNO_GUARD_HPP_INCLUDED #define CATCH_ERRNO_GUARD_HPP_INCLUDED +#include + namespace Catch { //! Simple RAII class that stores the value of `errno` //! at construction and restores it at destruction. - class ErrnoGuard { + class CATCH_DLL_PUBLIC ErrnoGuard { public: // Keep these outlined to avoid dragging in macros from @@ -21,7 +23,6 @@ namespace Catch { private: int m_oldErrno; }; - } #endif // CATCH_ERRNO_GUARD_HPP_INCLUDED diff --git a/src/catch2/internal/catch_exception_translator_registry.hpp b/src/catch2/internal/catch_exception_translator_registry.hpp index 465796d35b..40821ca0ea 100644 --- a/src/catch2/internal/catch_exception_translator_registry.hpp +++ b/src/catch2/internal/catch_exception_translator_registry.hpp @@ -9,14 +9,15 @@ #define CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED #include +#include #include - -#include #include +#include namespace Catch { - class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + class CATCH_DLL_PUBLIC ExceptionTranslatorRegistry + : public IExceptionTranslatorRegistry { public: ~ExceptionTranslatorRegistry() override; void registerTranslator( Detail::unique_ptr&& translator ); diff --git a/src/catch2/internal/catch_fatal_condition_handler.hpp b/src/catch2/internal/catch_fatal_condition_handler.hpp index 4a2818cb56..c69f268bb6 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.hpp +++ b/src/catch2/internal/catch_fatal_condition_handler.hpp @@ -8,10 +8,10 @@ #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED -#include -#include - #include +#include +#include +#include namespace Catch { @@ -25,7 +25,7 @@ namespace Catch { * Can only be instantiated once, and assumes that once a signal * is caught, the binary will end up terminating. Thus, there */ - class FatalConditionHandler { + class CATCH_DLL_PUBLIC FatalConditionHandler { bool m_started = false; // Install/disengage implementation for specific platform. @@ -52,7 +52,7 @@ namespace Catch { }; //! Simple RAII guard for (dis)engaging the FatalConditionHandler - class FatalConditionHandlerGuard { + class CATCH_DLL_PUBLIC FatalConditionHandlerGuard { FatalConditionHandler* m_handler; public: FatalConditionHandlerGuard(FatalConditionHandler* handler): diff --git a/src/catch2/internal/catch_floating_point_helpers.hpp b/src/catch2/internal/catch_floating_point_helpers.hpp index 3e73b3a723..0e6f6ddb73 100644 --- a/src/catch2/internal/catch_floating_point_helpers.hpp +++ b/src/catch2/internal/catch_floating_point_helpers.hpp @@ -8,18 +8,18 @@ #ifndef CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED #define CATCH_FLOATING_POINT_HELPERS_HPP_INCLUDED +#include #include - #include #include -#include #include +#include namespace Catch { namespace Detail { - uint32_t convertToBits(float f); - uint64_t convertToBits(double d); + CATCH_DLL_PUBLIC uint32_t convertToBits( float f ); + CATCH_DLL_PUBLIC uint64_t convertToBits( double d ); } // end namespace Detail diff --git a/src/catch2/internal/catch_lazy_expr.hpp b/src/catch2/internal/catch_lazy_expr.hpp index e69a72ef30..a165081248 100644 --- a/src/catch2/internal/catch_lazy_expr.hpp +++ b/src/catch2/internal/catch_lazy_expr.hpp @@ -8,13 +8,14 @@ #ifndef CATCH_LAZY_EXPR_HPP_INCLUDED #define CATCH_LAZY_EXPR_HPP_INCLUDED +#include #include namespace Catch { struct ITransientExpression; - class LazyExpression { + class CATCH_DLL_PUBLIC LazyExpression { friend class AssertionHandler; friend struct AssertionStats; friend class RunContext; @@ -32,7 +33,9 @@ namespace Catch { return m_transientExpression != nullptr; } - friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + CATCH_DLL_PUBLIC friend auto + operator<<( std::ostream& os, LazyExpression const& lazyExpr ) + -> std::ostream&; }; } // namespace Catch diff --git a/src/catch2/internal/catch_leak_detector.hpp b/src/catch2/internal/catch_leak_detector.hpp index eecdfca70d..7c23641a80 100644 --- a/src/catch2/internal/catch_leak_detector.hpp +++ b/src/catch2/internal/catch_leak_detector.hpp @@ -8,12 +8,13 @@ #ifndef CATCH_LEAK_DETECTOR_HPP_INCLUDED #define CATCH_LEAK_DETECTOR_HPP_INCLUDED +#include + namespace Catch { - struct LeakDetector { + struct CATCH_DLL_PUBLIC LeakDetector { LeakDetector(); ~LeakDetector(); }; - } #endif // CATCH_LEAK_DETECTOR_HPP_INCLUDED diff --git a/src/catch2/internal/catch_list.hpp b/src/catch2/internal/catch_list.hpp index 9caf4cf603..d1f95deee7 100644 --- a/src/catch2/internal/catch_list.hpp +++ b/src/catch2/internal/catch_list.hpp @@ -8,23 +8,21 @@ #ifndef CATCH_LIST_HPP_INCLUDED #define CATCH_LIST_HPP_INCLUDED +#include #include - #include #include - namespace Catch { class IEventListener; class Config; - - struct ReporterDescription { + struct CATCH_DLL_PUBLIC ReporterDescription { std::string name, description; }; - struct TagInfo { + struct CATCH_DLL_PUBLIC TagInfo { void add(StringRef spelling); std::string all() const; diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp index ecd78cabf8..69713372c6 100644 --- a/src/catch2/internal/catch_message_info.hpp +++ b/src/catch2/internal/catch_message_info.hpp @@ -8,15 +8,15 @@ #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED #define CATCH_MESSAGE_INFO_HPP_INCLUDED +#include +#include #include #include -#include - #include namespace Catch { - struct MessageInfo { + struct CATCH_DLL_PUBLIC MessageInfo { MessageInfo( StringRef _macroName, SourceLineInfo const& _lineInfo, ResultWas::OfType _type ); diff --git a/src/catch2/internal/catch_meta.hpp b/src/catch2/internal/catch_meta.hpp index 7d57358590..9f5fde0e37 100644 --- a/src/catch2/internal/catch_meta.hpp +++ b/src/catch2/internal/catch_meta.hpp @@ -8,14 +8,15 @@ #ifndef CATCH_META_HPP_INCLUDED #define CATCH_META_HPP_INCLUDED +#include #include namespace Catch { - template - struct always_false : std::false_type {}; + template + struct CATCH_DLL_PUBLIC always_false : std::false_type {}; - template struct true_given : std::true_type {}; - struct is_callable_tester { + template struct CATCH_DLL_PUBLIC true_given : std::true_type {}; + struct CATCH_DLL_PUBLIC is_callable_tester { template true_given()(std::declval()...))> static test(int); template diff --git a/src/catch2/internal/catch_noncopyable.hpp b/src/catch2/internal/catch_noncopyable.hpp index f08b157800..b22adf16b3 100644 --- a/src/catch2/internal/catch_noncopyable.hpp +++ b/src/catch2/internal/catch_noncopyable.hpp @@ -8,11 +8,13 @@ #ifndef CATCH_NONCOPYABLE_HPP_INCLUDED #define CATCH_NONCOPYABLE_HPP_INCLUDED +#include + namespace Catch { namespace Detail { //! Deriving classes become noncopyable and nonmovable - class NonCopyable { + class CATCH_DLL_PUBLIC NonCopyable { NonCopyable( NonCopyable const& ) = delete; NonCopyable( NonCopyable&& ) = delete; NonCopyable& operator=( NonCopyable const& ) = delete; diff --git a/src/catch2/internal/catch_optional.hpp b/src/catch2/internal/catch_optional.hpp index fb7ebbb699..7cb2cae90a 100644 --- a/src/catch2/internal/catch_optional.hpp +++ b/src/catch2/internal/catch_optional.hpp @@ -8,11 +8,13 @@ #ifndef CATCH_OPTIONAL_HPP_INCLUDED #define CATCH_OPTIONAL_HPP_INCLUDED +#include +#include + namespace Catch { // An optional type - template - class Optional { + template class CATCH_DLL_PUBLIC Optional { public: Optional() : nullableValue( nullptr ) {} Optional( T const& _value ) @@ -75,7 +77,8 @@ namespace Catch { return some(); } - friend bool operator==(Optional const& a, Optional const& b) { + CATCH_DLL_PUBLIC friend bool operator==( Optional const& a, + Optional const& b ) { if (a.none() && b.none()) { return true; } else if (a.some() && b.some()) { @@ -84,7 +87,8 @@ namespace Catch { return false; } } - friend bool operator!=(Optional const& a, Optional const& b) { + CATCH_DLL_PUBLIC friend bool operator!=( Optional const& a, + Optional const& b ) { return !( a == b ); } diff --git a/src/catch2/internal/catch_output_redirect.hpp b/src/catch2/internal/catch_output_redirect.hpp index fd7234ef14..d2c49e9502 100644 --- a/src/catch2/internal/catch_output_redirect.hpp +++ b/src/catch2/internal/catch_output_redirect.hpp @@ -8,17 +8,17 @@ #ifndef CATCH_OUTPUT_REDIRECT_HPP_INCLUDED #define CATCH_OUTPUT_REDIRECT_HPP_INCLUDED +#include +#include #include #include -#include - #include #include #include namespace Catch { - class RedirectedStream { + class CATCH_DLL_PUBLIC RedirectedStream { std::ostream& m_originalStream; std::ostream& m_redirectionStream; std::streambuf* m_prevBuf; @@ -28,7 +28,7 @@ namespace Catch { ~RedirectedStream(); }; - class RedirectedStdOut { + class CATCH_DLL_PUBLIC RedirectedStdOut { ReusableStringStream m_rss; RedirectedStream m_cout; public: @@ -39,7 +39,7 @@ namespace Catch { // StdErr has two constituent streams in C++, std::cerr and std::clog // This means that we need to redirect 2 streams into 1 to keep proper // order of writes - class RedirectedStdErr { + class CATCH_DLL_PUBLIC RedirectedStdErr { ReusableStringStream m_rss; RedirectedStream m_cerr; RedirectedStream m_clog; @@ -48,7 +48,7 @@ namespace Catch { auto str() const -> std::string; }; - class RedirectedStreams { + class CATCH_DLL_PUBLIC RedirectedStreams { public: RedirectedStreams(RedirectedStreams const&) = delete; RedirectedStreams& operator=(RedirectedStreams const&) = delete; @@ -70,7 +70,7 @@ namespace Catch { // to create a file inside system folder, thus requiring elevated // privileges for the binary), so we have to use tmpnam(_s) and // create the file ourselves there. - class TempFile { + class CATCH_DLL_PUBLIC TempFile { public: TempFile(TempFile const&) = delete; TempFile& operator=(TempFile const&) = delete; @@ -90,8 +90,7 @@ namespace Catch { #endif }; - - class OutputRedirect { + class CATCH_DLL_PUBLIC OutputRedirect { public: OutputRedirect(OutputRedirect const&) = delete; OutputRedirect& operator=(OutputRedirect const&) = delete; diff --git a/src/catch2/internal/catch_polyfills.hpp b/src/catch2/internal/catch_polyfills.hpp index e8444836a7..e1ec262e4e 100644 --- a/src/catch2/internal/catch_polyfills.hpp +++ b/src/catch2/internal/catch_polyfills.hpp @@ -8,9 +8,11 @@ #ifndef CATCH_POLYFILLS_HPP_INCLUDED #define CATCH_POLYFILLS_HPP_INCLUDED +#include + namespace Catch { - bool isnan(float f); - bool isnan(double d); + CATCH_DLL_PUBLIC bool isnan( float f ); + CATCH_DLL_PUBLIC bool isnan( double d ); } #endif // CATCH_POLYFILLS_HPP_INCLUDED diff --git a/src/catch2/internal/catch_preprocessor.hpp b/src/catch2/internal/catch_preprocessor.hpp index 00859b150a..5d3e546c3b 100644 --- a/src/catch2/internal/catch_preprocessor.hpp +++ b/src/catch2/internal/catch_preprocessor.hpp @@ -104,53 +104,128 @@ #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template