Browse Source

Tests interface: Verify expected warnings at destruction

Michael Ragazzon 1 year ago
parent
commit
b89db0e9f7
2 changed files with 9 additions and 0 deletions
  1. 7 0
      Tests/Source/Common/TestsInterface.cpp
  2. 2 0
      Tests/Source/Common/TestsInterface.h

+ 7 - 0
Tests/Source/Common/TestsInterface.cpp

@@ -31,6 +31,11 @@
 #include <RmlUi/Core/StringUtilities.h>
 #include <doctest.h>
 
+TestsSystemInterface::~TestsSystemInterface()
+{
+	SetNumExpectedWarnings(0);
+}
+
 double TestsSystemInterface::GetElapsedTime()
 {
 	return elapsed_time;
@@ -68,6 +73,8 @@ void TestsSystemInterface::SetNumExpectedWarnings(int in_num_expected_warnings)
 		{
 			Rml::String str = "Got unexpected number of warnings: \n";
 			Rml::StringUtilities::JoinString(str, warnings, '\n');
+			if (warnings.empty())
+				str += "(no warnings logged)";
 			CHECK_MESSAGE(num_logged_warnings == num_expected_warnings, str);
 		}
 

+ 2 - 0
Tests/Source/Common/TestsInterface.h

@@ -35,6 +35,8 @@
 
 class TestsSystemInterface : public Rml::SystemInterface {
 public:
+	~TestsSystemInterface();
+
 	double GetElapsedTime() override;
 
 	bool LogMessage(Rml::Log::Type type, const Rml::String& message) override;