Bladeren bron

Add ConsoleTestOutput

This TestOutput subclass simply outputs failures to stdout.  This is
handy for unit tests, since ExceptionTestOutput needs a *lot* of things
in order to work properly.
Marc Legendre 9 jaren geleden
bovenliggende
commit
98f2547d36

+ 2 - 0
Source/BansheeUtility/CMakeSources.cmake

@@ -167,11 +167,13 @@ set(BS_BANSHEEUTILITY_SRC_MATH
 set(BS_BANSHEEUTILITY_INC_TESTING
 	"Include/BsTestSuite.h"
 	"Include/BsTestOutput.h"
+	"Include/BsConsoleTestOutput.h"
 )
 
 set(BS_BANSHEEUTILITY_SRC_TESTING
 	"Source/BsTestSuite.cpp"
 	"Source/BsTestOutput.cpp"
+	"Source/BsConsoleTestOutput.cpp"
 )
 
 set(BS_BANSHEEUTILITY_SRC_SERIALIZATION

+ 26 - 0
Source/BansheeUtility/Include/BsConsoleTestOutput.h

@@ -0,0 +1,26 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsTestOutput.h"
+#include "BsPrerequisitesUtil.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Testing
+	 *  @{
+	 */
+
+	/** Outputs unit test failures to stdout. */
+	class BS_UTILITY_EXPORT ConsoleTestOutput : public TestOutput
+	{
+	public:
+		/** @copydoc TestOutput::outputFail */
+		void outputFail(const String& desc,
+		                const String& function,
+		                const String& file,
+		                long line) final override;
+	};
+
+	/** @} */
+}

+ 16 - 0
Source/BansheeUtility/Source/BsConsoleTestOutput.cpp

@@ -0,0 +1,16 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsConsoleTestOutput.h"
+
+#include <iostream>
+
+namespace BansheeEngine
+{
+	void ConsoleTestOutput::outputFail(const String& desc,
+	                                   const String& function,
+	                                   const String& file,
+	                                   long line)
+	{
+		std::cout << file << ":" << line << ": failure: " << desc << std::endl;
+	}
+}