MCPcopy Create free account
hub / github.com/Kitware/CMake / CheckGetLineFromStream

Function CheckGetLineFromStream

Source/kwsys/testSystemTools.cxx:967–1016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965}
966
967static bool CheckGetLineFromStream()
968{
969 std::string const fileWithFiveCharsOnFirstLine(TEST_SYSTEMTOOLS_SOURCE_DIR
970 "/README.rst");
971
972 kwsys::ifstream file(fileWithFiveCharsOnFirstLine.c_str(), std::ios::in);
973
974 if (!file) {
975 std::cerr << "Problem opening: " << fileWithFiveCharsOnFirstLine
976 << std::endl;
977 return false;
978 }
979
980 std::string line;
981 bool has_newline = false;
982 bool result;
983
984 file.seekg(0, std::ios::beg);
985 result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline,
986 std::string::npos);
987 if (!result || line.size() != 5) {
988 std::cerr << "First line does not have five characters: " << line.size()
989 << std::endl;
990 return false;
991 }
992
993 file.seekg(0, std::ios::beg);
994 result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline,
995 std::string::npos);
996 if (!result || line.size() != 5) {
997 std::cerr << "First line does not have five characters after rewind: "
998 << line.size() << std::endl;
999 return false;
1000 }
1001
1002 bool ret = true;
1003
1004 for (std::string::size_type size = 1; size <= 5; ++size) {
1005 file.seekg(0, std::ios::beg);
1006 result =
1007 kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, size);
1008 if (!result || line.size() != size) {
1009 std::cerr << "Should have read " << size << " characters but got "
1010 << line.size() << std::endl;
1011 ret = false;
1012 }
1013 }
1014
1015 return ret;
1016}
1017
1018static bool CheckGetLineFromStreamLongLine()
1019{

Callers 1

testSystemToolsFunction · 0.85

Calls 2

c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…