Function to read the "enwiki" file (entire or portion)
| 513 | |
| 514 | // Function to read the "enwiki" file (entire or portion) |
| 515 | std::string read_enwiki(const std::string& filepath, size_t max_bytes = 0) { |
| 516 | std::ifstream file(filepath, std::ios::binary); |
| 517 | if (!file) { |
| 518 | throw std::runtime_error("Cannot open enwiki file: " + filepath); |
| 519 | } |
| 520 | size_t file_size = get_file_size(filepath); |
| 521 | |
| 522 | // If max_bytes is specified and valid, limit the reading |
| 523 | size_t bytes_to_read = (max_bytes > 0 && max_bytes < file_size) ? max_bytes : file_size; |
| 524 | |
| 525 | std::string content(bytes_to_read, ' '); |
| 526 | file.read(&content[0], bytes_to_read); |
| 527 | |
| 528 | return content; |
| 529 | } |
| 530 | |
| 531 | // Function to verify byte-for-byte matching with detailed error reporting |
| 532 | bool verify_match(const std::string& original, const std::string& generated) { |
no test coverage detected