mirror of
				https://github.com/red0124/ssp.git
				synced 2025-10-30 12:56:45 +01:00 
			
		
		
		
	Update test helpers random file name generator
This commit is contained in:
		
							parent
							
								
									aacf690640
								
							
						
					
					
						commit
						e89e268280
					
				| @ -34,23 +34,13 @@ struct buffer { | |||||||
| 
 | 
 | ||||||
| [[maybe_unused]] inline buffer buff; | [[maybe_unused]] inline buffer buff; | ||||||
| 
 | 
 | ||||||
| std::string time_now_rand() { |  | ||||||
|     std::stringstream ss; |  | ||||||
|     auto t = std::time(nullptr); |  | ||||||
|     auto tm = *std::localtime(&t); |  | ||||||
|     ss << std::put_time(&tm, "%d%m%Y%H%M%S"); |  | ||||||
|     srand(time(nullptr)); |  | ||||||
|     return ss.str() + std::to_string(rand()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| struct unique_file_name { | struct unique_file_name { | ||||||
|     static inline int i = 0; |     std::string name; | ||||||
| 
 | 
 | ||||||
|     const std::string name; |     unique_file_name(const std::string& test) { | ||||||
| 
 |         do { | ||||||
|     unique_file_name(const std::string& test) |             name = std::tmpnam(nullptr) + std::string{"_random_test_"} + test; | ||||||
|         : name{"random_" + test + "_" + std::to_string(i++) + "_" + |         } while (std::filesystem::exists(name)); | ||||||
|                time_now_rand() + "_file.csv"} { |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     ~unique_file_name() { |     ~unique_file_name() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user