diff options
author | Brad King <brad.king@kitware.com> | 2017-01-17 14:05:05 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2017-01-17 14:05:05 (GMT) |
commit | c9e76c3e04ad2dc4f50297451f2c38fdef7ae6b6 (patch) | |
tree | 56c096d360d47831c5482d46930e1999d36583dc /Source/kwsys/testSystemTools.cxx | |
parent | 524c56431859cfc8a96a8dad752f131804982166 (diff) | |
parent | ee77941a1fdf3a617207b00a7f2e9315eaef7b31 (diff) | |
download | CMake-c9e76c3e04ad2dc4f50297451f2c38fdef7ae6b6.zip CMake-c9e76c3e04ad2dc4f50297451f2c38fdef7ae6b6.tar.gz CMake-c9e76c3e04ad2dc4f50297451f2c38fdef7ae6b6.tar.bz2 |
Merge topic 'update-kwsys'
ee77941a Merge branch 'upstream-KWSys' into update-kwsys
219c7bdc KWSys 2017-01-16 (a423d829)
Diffstat (limited to 'Source/kwsys/testSystemTools.cxx')
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index b04f2cb..8e1ea25 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -6,11 +6,13 @@ #pragma warning(disable : 4786) #endif +#include KWSYS_HEADER(FStream.hxx) #include KWSYS_HEADER(SystemTools.hxx) // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 +#include "FStream.hxx.in" #include "SystemTools.hxx.in" #endif @@ -857,6 +859,55 @@ static bool CheckFind() return res; } +static bool CheckGetLineFromStream() +{ + const std::string fileWithFiveCharsOnFirstLine(TEST_SYSTEMTOOLS_SOURCE_DIR + "/README.rst"); + + kwsys::ifstream file(fileWithFiveCharsOnFirstLine.c_str(), std::ios::in); + + if (!file) { + std::cerr << "Problem opening: " << fileWithFiveCharsOnFirstLine + << std::endl; + return false; + } + + std::string line; + bool has_newline = false; + bool result; + + file.seekg(0, std::ios::beg); + result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1); + if (!result || line.size() != 5) { + std::cerr << "First line does not have five characters: " << line.size() + << std::endl; + return false; + } + + file.seekg(0, std::ios::beg); + result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1); + if (!result || line.size() != 5) { + std::cerr << "First line does not have five characters after rewind: " + << line.size() << std::endl; + return false; + } + + bool ret = true; + + for (size_t size = 1; size <= 5; ++size) { + file.seekg(0, std::ios::beg); + result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, + static_cast<long>(size)); + if (!result || line.size() != size) { + std::cerr << "Should have read " << size << " characters but got " + << line.size() << std::endl; + ret = false; + } + } + + return ret; +} + //---------------------------------------------------------------------------- int testSystemTools(int, char* []) { @@ -893,5 +944,7 @@ int testSystemTools(int, char* []) res &= CheckFind(); + res &= CheckGetLineFromStream(); + return res ? 0 : 1; } |