mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Moved enum tests that depend on internals to IntrospectiveTests.
- also factored out makeEnumInfo, so tests don't need to touch registry - and added usage test that involves namespace
This commit is contained in:
		| @@ -38,9 +38,10 @@ namespace Catch { | ||||
|             return "{** unexpected enum value **}"; | ||||
|         } | ||||
|  | ||||
|         EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { | ||||
|         std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { | ||||
|             std::unique_ptr<EnumInfo> enumInfo( new EnumInfo ); | ||||
|             enumInfo->m_name = enumName; | ||||
|             enumInfo->m_values.reserve( values.size() ); | ||||
|  | ||||
|             const auto valueNames = Catch::Detail::parseEnums( allValueNames ); | ||||
|             assert( valueNames.size() == values.size() ); | ||||
| @@ -48,6 +49,11 @@ namespace Catch { | ||||
|             for( auto value : values ) | ||||
|                 enumInfo->m_values.push_back({ value, valueNames[i++] }); | ||||
|  | ||||
|             return enumInfo; | ||||
|         } | ||||
|  | ||||
|         EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) { | ||||
|             auto enumInfo = makeEnumInfo( enumName, allValueNames, values ); | ||||
|             EnumInfo* raw = enumInfo.get(); | ||||
|             m_enumInfos.push_back( std::move( enumInfo ) ); | ||||
|             return *raw; | ||||
|   | ||||
| @@ -16,11 +16,13 @@ namespace Catch { | ||||
|  | ||||
|     namespace Detail { | ||||
|  | ||||
|         std::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ); | ||||
|  | ||||
|         class EnumValuesRegistry : public IMutableEnumValuesRegistry { | ||||
|  | ||||
|             std::vector<std::unique_ptr<EnumInfo>> m_enumInfos; | ||||
|  | ||||
|             EnumInfo const& registerEnum(StringRef enumName, StringRef allEnums, std::vector<int> const& values) override; | ||||
|             EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override; | ||||
|         }; | ||||
|  | ||||
|         std::vector<std::string> parseEnums( StringRef enums ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil nash
					Phil nash