Fix lagi_thes unit tests on Windows

The thes file was using \r\n line ends, and \r was not stripped, causing the encoding string has a \r at its end.
Use binary mode and always use \n as line ends.
This commit is contained in:
wangqr 2019-09-18 18:11:18 -04:00 committed by Thomas Goyne
parent 336745cdb2
commit 57ee580c0f
1 changed files with 4 additions and 3 deletions

View File

@ -26,13 +26,14 @@ protected:
std::string dat_path;
void SetUp() override {
using std::endl;
// Use '\n' on all platforms, as we are mapping the file to memory as binary data, and readline can only handle '\n'
const char endl = '\n';
idx_path = "data/thes.idx";
dat_path = "data/thes.dat";
std::ofstream idx(idx_path.c_str());
std::ofstream dat(dat_path.c_str());
std::ofstream idx(idx_path.c_str(), std::ios_base::binary);
std::ofstream dat(dat_path.c_str(), std::ios_base::binary);
idx << "UTF-8" << endl;
dat << "UTF-8" << endl;