#ifndef MONAD_SHARED
#define MONAD_SHARED

#include "util.h"
#include "pipestream.h"

namespace monad_shared
{

	namespace version
	{
		extern const char * official_name;
		extern const char * version_name;
		extern const char * date;
	}

	void printInfo();

	struct unit_test
	{
		typedef std::string return_type;
		typedef return_type (*function)(unit_test & this_test);
		static const char * pass_string;

		std::string errormsg;
		std::string output;
		function func;
		const char * name;
		util::pipestream * checkstream;
		long timeout;
		long time;
		int32_t points;
		int32_t valgrind_flags;
		bool is_valgrind;

		unit_test(const char * name_,
		          unit_test::function func_,
		          int32_t points_,
		          long timeout_,
		          bool is_valgrind_)
			: errormsg("message not set / proxy crashed"),
			  func(func_),
			  name(name_),
			  checkstream(NULL),
			  timeout(timeout_),
			  time(-1),
			  points(points_),
			  valgrind_flags(-1),
			  is_valgrind(is_valgrind_) { }

		bool passed() const
		{
			return errormsg == pass_string;
		}
	};

	namespace output
	{
		void set_error_message();
		void header(const std::string & title);
		void total_score(int32_t score, int32_t outof);
		void warning(const std::string & message);
		void testname(const unit_test & curr_test, int32_t max_testname_len, int32_t max_points_len);
		void detailed_info(const unit_test & curr_test);
		std::string passed_string();
		std::string failed_string();
	} // namespace output

}

#endif // MONAD_SHARED