Skip to content
Snippets Groups Projects
monad_shared.h 1.49 KiB
Newer Older
  • Learn to ignore specific revisions
  • toole1's avatar
    toole1 committed
    #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;
    
    
    toole1's avatar
    toole1 committed
    		unit_test(const char * name_,
    
    toole1's avatar
    toole1 committed
    		          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);
    
    toole1's avatar
    toole1 committed
    		void total_score(int32_t score, int32_t outof);
    
    toole1's avatar
    toole1 committed
    		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);
    
    toole1's avatar
    toole1 committed
    		std::string passed_string();
    		std::string failed_string();
    
    toole1's avatar
    toole1 committed
    	} // namespace output
    
    toole1's avatar
    toole1 committed
    
    
    toole1's avatar
    toole1 committed
    }
    
    #endif // MONAD_SHARED