Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Catch3/Session.cpp
diff options
context:
space:
mode:
authorLeitwolf2026-10-25 10:31:36 +0300
committerGitHub2026-10-25 10:31:36 +0300
commitd2e3e074bb2e1b8ffd9fc990d0b87667ea602f58 (patch)
tree0bce4462b2e190c39b3e1c5f697e3e4abd1a5e2a /src/Progmasoft/Catch3/Session.cpp
parent13f81a480a93807c14dddb5abdb97355ced4d4c5 (diff)
parent126dc333564cb72b5115d9a9242d66694694b6d0 (diff)
downloadcatch3-d2e3e074bb2e1b8ffd9fc990d0b87667ea602f58.tar.gz
Merge pull request #18 from Progmasoft/build/catch3-identity
Give Catch3 its own build names and headers
Diffstat (limited to 'src/Progmasoft/Catch3/Session.cpp')
-rw-r--r--src/Progmasoft/Catch3/Session.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/Progmasoft/Catch3/Session.cpp b/src/Progmasoft/Catch3/Session.cpp
new file mode 100644
index 00000000..cc9ef38d
--- /dev/null
+++ b/src/Progmasoft/Catch3/Session.cpp
@@ -0,0 +1,58 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+#include <Progmasoft/Catch3/Session.hpp>
+#include <Progmasoft/Catch3/Internal/Context.hpp>
+#include <Progmasoft/Catch3/Internal/Enforce.hpp>
+#include <Progmasoft/Catch3/Internal/WindowsHProxy.hpp>
+#include <Progmasoft/Catch3/Interfaces/IRegistryHub.hpp>
+
+#include <Progmasoft/Catch3/Runner.hpp>
+
+namespace Catch {
+
+ Session::Session() {
+ static bool alreadyInstantiated = false;
+ if( alreadyInstantiated ) {
+ CATCH_TRY { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); }
+ CATCH_CATCH_ALL { getMutableRegistryHub().registerStartupException(); }
+ }
+ alreadyInstantiated = true;
+ }
+ Session::~Session() {
+ Catch::cleanUp();
+ }
+
+ void Session::showHelp() const {
+ Progmasoft::Catch3::PrintHelp( m_arguments.empty() ? std::string( "tests" )
+ : m_arguments.front() );
+ }
+
+ int Session::applyCommandLine( int argc, char const * const * argv ) {
+ m_arguments.assign( argv, argv + argc );
+ return 0;
+ }
+
+#if defined(CATCH_CONFIG_WCHAR) && defined(_WIN32) && defined(UNICODE)
+ int Session::applyCommandLine( int argc, wchar_t const * const * argv ) {
+ m_arguments.clear();
+ for ( int i = 0; i < argc; ++i ) {
+ int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, nullptr, 0, nullptr, nullptr );
+ std::string utf8( static_cast<std::size_t>( bufSize ), '\0' );
+ WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, &utf8[0], bufSize, nullptr, nullptr );
+ if ( !utf8.empty() ) { utf8.pop_back(); } // the terminator
+ m_arguments.push_back( utf8 );
+ }
+ return 0;
+ }
+#endif
+
+ int Session::run() {
+ return Progmasoft::Catch3::RunTests( m_arguments );
+ }
+
+} // end namespace Catch