Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct ODBC test function #1522

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions test/odbc/mssqlodbc/test_data_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,20 @@ bool is_empty(std::ifstream& pFile)

// Helper function that reads from a file and returns the contents as a string
string readFromFile(string relativePath) {
int bufferLen = 1024;
char * buffer = new char [bufferLen];
char * fname;

std::ifstream dataFile(relativePath);
if (is_empty(dataFile)) {
return "";
}

std::filesystem::path fp{relativePath};
int fsize = std::filesystem::file_size(fp);
while (fsize > bufferLen){
dataFile.read(buffer, bufferLen);
fsize -= bufferLen;

auto stream = std::ifstream(relativePath.data());
constexpr auto read_size = std::size_t(4096);
auto out = std::string();
auto buf = std::string(read_size,'\0');
while (stream.read(& buf[0], read_size)) {
out.append(buf, 0, stream.gcount());
}
dataFile.read(buffer, fsize);
dataFile.close();
return string(buffer);
out.append(buf, 0, stream.gcount());
return out;
}

// Helper function that iterates over & fetches data, and compares retrieved value to expected value
Expand Down