mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 04:26:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #ifndef OPENMW_COMPONENTS_TESTING_EXPECTERROR_H
 | |
| #define OPENMW_COMPONENTS_TESTING_EXPECTERROR_H
 | |
| 
 | |
| #include <gmock/gmock.h>
 | |
| #include <gtest/gtest.h>
 | |
| 
 | |
| #include <exception>
 | |
| 
 | |
| #define EXPECT_ERROR(X, ERR_SUBSTR)                                                                                    \
 | |
|     try                                                                                                                \
 | |
|     {                                                                                                                  \
 | |
|         X;                                                                                                             \
 | |
|         FAIL() << "Expected error";                                                                                    \
 | |
|     }                                                                                                                  \
 | |
|     catch (const std::exception& e)                                                                                    \
 | |
|     {                                                                                                                  \
 | |
|         EXPECT_THAT(e.what(), ::testing::HasSubstr(ERR_SUBSTR));                                                       \
 | |
|     }
 | |
| 
 | |
| #endif
 |