File tree Expand file tree Collapse file tree 6 files changed +43
-2
lines changed Expand file tree Collapse file tree 6 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ set(INTERNAL_HEADERS
137137 ${SOURCES_DIR} /internal /catch_string_manip.hpp
138138 ${SOURCES_DIR} /internal /catch_stringref.hpp
139139 ${SOURCES_DIR} /catch_tag_alias.hpp
140+ ${SOURCES_DIR} /catch_get_random_seed.hpp
140141 ${SOURCES_DIR} /catch_tag_alias_autoregistrar.hpp
141142 ${SOURCES_DIR} /internal /catch_tag_alias_registry.hpp
142143 ${SOURCES_DIR} /catch_test_case_info.hpp
@@ -230,6 +231,7 @@ set(IMPL_SOURCES
230231 ${SOURCES_DIR} /matchers/catch_matchers_predicate.cpp
231232 ${SOURCES_DIR} /matchers/internal /catch_matchers_impl.cpp
232233 ${SOURCES_DIR} /catch_tag_alias_autoregistrar.cpp
234+ ${SOURCES_DIR} /catch_get_random_seed.cpp
233235 ${SOURCES_DIR} /internal /catch_decomposer.cpp
234236 ${SOURCES_DIR} /internal /catch_errno_guard.cpp
235237 ${SOURCES_DIR} /internal /catch_lazy_expr.cpp
Original file line number Diff line number Diff line change 2727#include < catch2/catch_assertion_info.hpp>
2828#include < catch2/catch_assertion_result.hpp>
2929#include < catch2/catch_config.hpp>
30+ #include < catch2/catch_get_random_seed.hpp>
3031#include < catch2/catch_message.hpp>
3132#include < catch2/catch_section_info.hpp>
3233#include < catch2/catch_session.hpp>
Original file line number Diff line number Diff line change 1+
2+ // Copyright Catch2 Authors
3+ // Distributed under the Boost Software License, Version 1.0.
4+ // (See accompanying file LICENSE_1_0.txt or copy at
5+ // https://www.boost.org/LICENSE_1_0.txt)
6+
7+ // SPDX-License-Identifier: BSL-1.0
8+
9+ #include < catch2/catch_get_random_seed.hpp>
10+
11+ #include < catch2/internal/catch_context.hpp>
12+ #include < catch2/catch_config.hpp>
13+
14+ namespace Catch {
15+ std::uint32_t getSeed () {
16+ return getCurrentContext ().getConfig ()->rngSeed ();
17+ }
18+ }
Original file line number Diff line number Diff line change 1+
2+ // Copyright Catch2 Authors
3+ // Distributed under the Boost Software License, Version 1.0.
4+ // (See accompanying file LICENSE_1_0.txt or copy at
5+ // https://www.boost.org/LICENSE_1_0.txt)
6+
7+ // SPDX-License-Identifier: BSL-1.0
8+ #ifndef CATCH_GET_RANDOM_SEED_HPP_INCLUDED
9+ #define CATCH_GET_RANDOM_SEED_HPP_INCLUDED
10+
11+ #include < cstdint>
12+
13+ namespace Catch {
14+ // ! Returns Catch2's current RNG seed.
15+ std::uint32_t getSeed ();
16+ }
17+
18+ #endif // CATCH_GET_RANDOM_SEED_HPP_INCLUDED
Original file line number Diff line number Diff line change 77// SPDX-License-Identifier: BSL-1.0
88#include < catch2/reporters/catch_reporter_compact.hpp>
99
10+ #include < catch2/catch_get_random_seed.hpp>
1011#include < catch2/catch_test_spec.hpp>
1112#include < catch2/reporters/catch_reporter_helpers.hpp>
1213#include < catch2/interfaces/catch_interfaces_config.hpp>
@@ -261,7 +262,7 @@ class AssertionPrinter {
261262 << serializeFilters ( m_config->getTestsOrTags () )
262263 << ' \n ' ;
263264 }
264- m_stream << " RNG seed: " << m_config-> rngSeed () << ' \n ' ;
265+ m_stream << " RNG seed: " << getSeed () << ' \n ' ;
265266 }
266267
267268 void CompactReporter::assertionEnded ( AssertionStats const & _assertionStats ) {
Original file line number Diff line number Diff line change 1919#include < catch2/internal/catch_console_width.hpp>
2020#include < catch2/reporters/catch_reporter_helpers.hpp>
2121#include < catch2/internal/catch_move_and_forward.hpp>
22+ #include < catch2/catch_get_random_seed.hpp>
2223
2324#include < cstdio>
2425
@@ -500,7 +501,7 @@ void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
500501 m_stream << m_colour->guardColour ( Colour::BrightYellow ) << " Filters: "
501502 << serializeFilters ( m_config->getTestsOrTags () ) << ' \n ' ;
502503 }
503- m_stream << " Randomness seeded to: " << m_config-> rngSeed () << ' \n ' ;
504+ m_stream << " Randomness seeded to: " << getSeed () << ' \n ' ;
504505}
505506
506507void ConsoleReporter::lazyPrint () {
You can’t perform that action at this time.
0 commit comments