aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h')
-rw-r--r--Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h b/Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h
new file mode 100644
index 00000000..91d36dec
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/test/TestToolsTracker.h
@@ -0,0 +1,92 @@
+/*
+ * TestToolsTracker.h
+ * ------------------
+ * Purpose: Unit test framework for OpenMPT.
+ * Notes : Really basic functionality that relies on a debugger that catches
+ * exceptions and breaks right at the spot where it gets thrown.
+ * Authors: OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#pragma once
+
+#include "openmpt/all/BuildSettings.hpp"
+
+
+#ifdef ENABLE_TESTS
+#ifdef MODPLUG_TRACKER
+
+
+#include "mpt/test/test.hpp"
+
+
+OPENMPT_NAMESPACE_BEGIN
+
+
+namespace Test {
+
+
+#if MPT_COMPILER_MSVC
+// With MSVC, break directly using __debugbreak intrinsic instead of calling DebugBreak which breaks one stackframe deeper than we want
+#define MyDebugBreak() __debugbreak()
+#else
+#define MyDebugBreak() DebugBreak()
+#endif
+
+
+class mpt_test_reporter
+ : public mpt::test::silent_reporter
+{
+public:
+ mpt_test_reporter() = default;
+ ~mpt_test_reporter() override = default;
+public:
+ inline void immediate_breakpoint() override {
+ MyDebugBreak();
+ }
+};
+
+
+// Verify that given parameters are 'equal'. Break directly into the debugger if not.
+// The exact meaning of equality is based on operator== of the compared types.
+#define VERIFY_EQUAL(x,y) \
+ do { \
+ if(!((x) == (y))) { \
+ MyDebugBreak(); \
+ } \
+ } while(0) \
+/**/
+
+// Like VERIFY_EQUAL, only differs for libopenmpt
+#define VERIFY_EQUAL_NONCONT VERIFY_EQUAL
+
+// Like VERIFY_EQUAL, only differs for libopenmpt
+#define VERIFY_EQUAL_QUIET_NONCONT VERIFY_EQUAL
+
+#define VERIFY_EQUAL_EPS(x,y,eps) \
+ do { \
+ if(std::abs((x) - (y)) > (eps)) { \
+ MyDebugBreak(); \
+ } \
+ } while(0) \
+/**/
+
+
+#define DO_TEST(func) \
+ do { \
+ if(IsDebuggerPresent()) { \
+ func(); \
+ } \
+ } while(0) \
+/**/
+
+
+} // namespace Test
+
+
+OPENMPT_NAMESPACE_END
+
+
+#endif // MODPLUG_TRACKER
+#endif // ENABLE_TESTS