mirror of
				https://github.com/red0124/ssp.git
				synced 2025-10-29 20:36:45 +01:00 
			
		
		
		
	Apply minor changes to tests
This commit is contained in:
		
							parent
							
								
									a7ea9e42e5
								
							
						
					
					
						commit
						2b132bc33a
					
				| @ -16,6 +16,7 @@ | ||||
| #include <cstdlib> | ||||
| #endif | ||||
| 
 | ||||
| // TODO try from_chars for integer conversions
 | ||||
| namespace ss { | ||||
| 
 | ||||
| ////////////////
 | ||||
|  | ||||
| @ -574,7 +574,6 @@ private: | ||||
|             : delim_{delim}, file_{fopen(file_name_.c_str(), "rb")} { | ||||
|         } | ||||
| 
 | ||||
|         // TODO test for next_line_size_
 | ||||
|         reader(reader&& other) | ||||
|             : buffer_{other.buffer_}, | ||||
|               next_line_buffer_{other.next_line_buffer_}, | ||||
| @ -771,12 +770,13 @@ private: | ||||
|                             const char* const second, size_t second_size) { | ||||
|             // TODO make buffer_size an argument
 | ||||
|             next_line_buffer_size_ = first_size + second_size + 3; | ||||
|             first = static_cast<char*>( | ||||
|             auto new_first = static_cast<char*>( | ||||
|                 realloc(static_cast<void*>(first), next_line_buffer_size_)); | ||||
|             if (!first) { | ||||
|                 // TODO restore first in order to prevent memory leak
 | ||||
|                 throw std::bad_alloc{}; | ||||
|             } | ||||
| 
 | ||||
|             first = new_first; | ||||
|             std::copy_n(second, second_size + 1, first + first_size); | ||||
|             first_size += second_size; | ||||
|         } | ||||
|  | ||||
| @ -25,7 +25,6 @@ private: | ||||
|     constexpr static auto throw_on_error = setup<Options...>::throw_on_error; | ||||
|     constexpr static auto is_const_line = !quote::enabled && !escape::enabled; | ||||
| 
 | ||||
|     // TODO make error_type none if throw_on_error
 | ||||
|     using error_type = std::conditional_t<string_error, std::string, bool>; | ||||
| 
 | ||||
| public: | ||||
| @ -149,7 +148,6 @@ private: | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // TODO rename with handle error
 | ||||
|     void handle_error_unterminated_escape() { | ||||
|         constexpr static auto error_msg = | ||||
|             "unterminated escape at the end of the line"; | ||||
|  | ||||
| @ -6,11 +6,11 @@ TEST_CASE("testing extract functions for floating point values") { | ||||
|     CHECK_FLOATING_CONVERSION(123.456, float); | ||||
|     CHECK_FLOATING_CONVERSION(123.456, double); | ||||
| 
 | ||||
|     CHECK_FLOATING_CONVERSION(69, float); | ||||
|     CHECK_FLOATING_CONVERSION(69, double); | ||||
|     CHECK_FLOATING_CONVERSION(59, float); | ||||
|     CHECK_FLOATING_CONVERSION(59, double); | ||||
| 
 | ||||
|     CHECK_FLOATING_CONVERSION(420., float); | ||||
|     CHECK_FLOATING_CONVERSION(420., double); | ||||
|     CHECK_FLOATING_CONVERSION(4210., float); | ||||
|     CHECK_FLOATING_CONVERSION(4210., double); | ||||
| 
 | ||||
|     CHECK_FLOATING_CONVERSION(0.123, float); | ||||
|     CHECK_FLOATING_CONVERSION(0.123, double); | ||||
|  | ||||
| @ -125,7 +125,14 @@ void test_various_cases() { | ||||
|         ss::parser<ss::string_error> p2{f.name, ","}; | ||||
|         std::vector<X> i2; | ||||
| 
 | ||||
|         auto move_rotate = [&] { | ||||
|             auto p1 = std::move(p); | ||||
|             p0 = std::move(p1); | ||||
|             p = std::move(p0); | ||||
|         }; | ||||
| 
 | ||||
|         while (!p.eof()) { | ||||
|             move_rotate(); | ||||
|             auto a = p.template get_next<int, double, std::string>(); | ||||
|             i.emplace_back(ss::to_object<X>(a)); | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user