|
@@ -6,11 +6,13 @@
|
|
|
#pragma warning(disable : 4786)
|
|
#pragma warning(disable : 4786)
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
+#include KWSYS_HEADER(FStream.hxx)
|
|
|
#include KWSYS_HEADER(SystemTools.hxx)
|
|
#include KWSYS_HEADER(SystemTools.hxx)
|
|
|
|
|
|
|
|
// Work-around CMake dependency scanning limitation. This must
|
|
// Work-around CMake dependency scanning limitation. This must
|
|
|
// duplicate the above list of headers.
|
|
// duplicate the above list of headers.
|
|
|
#if 0
|
|
#if 0
|
|
|
|
|
+#include "FStream.hxx.in"
|
|
|
#include "SystemTools.hxx.in"
|
|
#include "SystemTools.hxx.in"
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
@@ -857,6 +859,55 @@ static bool CheckFind()
|
|
|
return res;
|
|
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* [])
|
|
int testSystemTools(int, char* [])
|
|
|
{
|
|
{
|
|
@@ -893,5 +944,7 @@ int testSystemTools(int, char* [])
|
|
|
|
|
|
|
|
res &= CheckFind();
|
|
res &= CheckFind();
|
|
|
|
|
|
|
|
|
|
+ res &= CheckGetLineFromStream();
|
|
|
|
|
+
|
|
|
return res ? 0 : 1;
|
|
return res ? 0 : 1;
|
|
|
}
|
|
}
|