Fix magic enum range
This commit is contained in:
		
					parent
					
						
							
								c75f04fcf1
							
						
					
				
			
			
				commit
				
					
						89f1022430
					
				
			
		
					 4 changed files with 35 additions and 2 deletions
				
			
		| 
						 | 
					@ -18,6 +18,7 @@ add_executable(
 | 
				
			||||||
  distributed_work.cpp
 | 
					  distributed_work.cpp
 | 
				
			||||||
  election.cpp
 | 
					  election.cpp
 | 
				
			||||||
  election_scheduler.cpp
 | 
					  election_scheduler.cpp
 | 
				
			||||||
 | 
					  enums.cpp
 | 
				
			||||||
  epochs.cpp
 | 
					  epochs.cpp
 | 
				
			||||||
  frontiers_confirmation.cpp
 | 
					  frontiers_confirmation.cpp
 | 
				
			||||||
  gap_cache.cpp
 | 
					  gap_cache.cpp
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										23
									
								
								nano/core_test/enums.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								nano/core_test/enums.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					#include <nano/lib/stats_enums.hpp>
 | 
				
			||||||
 | 
					#include <nano/test_common/system.hpp>
 | 
				
			||||||
 | 
					#include <nano/test_common/testutil.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <gtest/gtest.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST (enums, stat_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ASSERT_FALSE (nano::to_string (static_cast<nano::stat::type> (0)).empty ());
 | 
				
			||||||
 | 
						ASSERT_FALSE (nano::to_string (nano::stat::type::_last).empty ());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST (enums, stat_detail)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ASSERT_FALSE (nano::to_string (static_cast<nano::stat::detail> (0)).empty ());
 | 
				
			||||||
 | 
						ASSERT_FALSE (nano::to_string (nano::stat::detail::_last).empty ());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEST (enums, stat_dir)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ASSERT_FALSE (nano::to_string (static_cast<nano::stat::dir> (0)).empty ());
 | 
				
			||||||
 | 
						ASSERT_FALSE (nano::to_string (nano::stat::dir::_last).empty ());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										3
									
								
								nano/lib/magic_enum.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								nano/lib/magic_enum.hpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					#define MAGIC_ENUM_RANGE_MIN 0
 | 
				
			||||||
 | 
					#define MAGIC_ENUM_RANGE_MAX 256
 | 
				
			||||||
 | 
					#include <magic_enum.hpp>
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <magic_enum.hpp>
 | 
					#include <nano/lib/magic_enum.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace nano::stat
 | 
					namespace nano::stat
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,8 @@ enum class type : uint8_t
 | 
				
			||||||
	bootstrap_server,
 | 
						bootstrap_server,
 | 
				
			||||||
	active,
 | 
						active,
 | 
				
			||||||
	backlog,
 | 
						backlog,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_last // Must be the last enum
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Optional detail type */
 | 
					/** Optional detail type */
 | 
				
			||||||
| 
						 | 
					@ -250,13 +252,17 @@ enum class detail : uint8_t
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// backlog
 | 
						// backlog
 | 
				
			||||||
	activated,
 | 
						activated,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_last // Must be the last enum
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Direction of the stat. If the direction is irrelevant, use in */
 | 
					/** Direction of the stat. If the direction is irrelevant, use in */
 | 
				
			||||||
enum class dir : uint8_t
 | 
					enum class dir : uint8_t
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	in,
 | 
						in,
 | 
				
			||||||
	out
 | 
						out,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_last // Must be the last enum
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue