diff options
Diffstat (limited to 'sources/shiboken6/tests/libsample/exceptiontest.cpp')
-rw-r--r-- | sources/shiboken6/tests/libsample/exceptiontest.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/libsample/exceptiontest.cpp b/sources/shiboken6/tests/libsample/exceptiontest.cpp new file mode 100644 index 000000000..56144e086 --- /dev/null +++ b/sources/shiboken6/tests/libsample/exceptiontest.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "exceptiontest.h" + +class TestException : public std::exception +{ +public: + const char *what() const noexcept override + { return "TestException"; } +}; + +ExceptionTest::ExceptionTest() = default; + +int ExceptionTest::intThrowStdException(bool doThrow) +{ + if (doThrow) + throw TestException(); + return 1; +} + +void ExceptionTest::voidThrowStdException(bool doThrow) +{ + if (doThrow) + throw TestException(); +} + +int ExceptionTest::intThrowInt(bool doThrow) +{ + if (doThrow) + throw 42; + return 1; +} + +void ExceptionTest::voidThrowInt(bool doThrow) +{ + if (doThrow) + throw 42; +} + +ExceptionTest *ExceptionTest::create(bool doThrow) +{ + if (doThrow) + throw TestException(); + return new ExceptionTest; +} |